From d3232ebd27735dba212b848397e915d341f2fcde Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Thu, 26 Aug 2004 18:17:47 +0000 Subject: [PATCH] Big improvement to type encapsulation iterator_type, expersion_type, functo_type etc private svn path=/trunk/boost/boost/numeric/ublas/; revision=24769 --- include/boost/numeric/ublas/matrix.hpp | 68 ++++-- .../boost/numeric/ublas/matrix_expression.hpp | 211 +++++++++++------- include/boost/numeric/ublas/matrix_sparse.hpp | 60 +++-- include/boost/numeric/ublas/storage.hpp | 21 +- include/boost/numeric/ublas/vector.hpp | 53 +++-- .../boost/numeric/ublas/vector_expression.hpp | 107 +++++---- .../boost/numeric/ublas/vector_of_vector.hpp | 16 +- include/boost/numeric/ublas/vector_sparse.hpp | 36 ++- 8 files changed, 384 insertions(+), 188 deletions(-) diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index b4a0b95c..f11deb20 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -43,19 +43,19 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef F functor_type; typedef A array_type; typedef const A const_array_type; typedef const matrix const_self_type; typedef matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else typedef const matrix_reference const_closure_type; #endif typedef matrix_reference closure_type; - typedef typename A::const_iterator const_iterator_type; - typedef typename A::iterator iterator_type; typedef dense_tag storage_category; // This could be better for performance, // typedef typename unknown_orientation_tag orientation_category; @@ -264,6 +264,13 @@ namespace boost { namespace numeric { namespace ublas { std::fill (data ().begin (), data ().end (), value_type ()); } + // Iterator types + private: + // Use the storage array iterator + typedef typename A::const_iterator const_iterator_type; + typedef typename A::iterator iterator_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -321,7 +328,6 @@ namespace boost { namespace numeric { namespace ublas { #endif } - // Iterators simply are pointers. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator1: @@ -986,21 +992,19 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef F functor_type; typedef A array_type; typedef const A const_array_type; typedef const vector_of_vector const_self_type; typedef vector_of_vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else typedef const matrix_reference const_closure_type; #endif typedef matrix_reference closure_type; - typedef typename A::const_iterator vector_const_iterator_type; - typedef typename A::iterator vector_iterator_type; - typedef typename A::value_type::const_iterator const_iterator_type; - typedef typename A::value_type::iterator iterator_type; typedef dense_tag storage_category; // This could be better for performance, // typedef typename unknown_orientation_tag orientation_category; @@ -1191,6 +1195,14 @@ namespace boost { namespace numeric { namespace ublas { std::fill (data () [k].begin (), data () [k].end (), value_type ()); } + // Iterator types + private: + // Use the vector iterator + typedef typename A::const_iterator vector_const_iterator_type; + typedef typename A::iterator vector_iterator_type; + typedef typename A::value_type::const_iterator const_iterator_type; + typedef typename A::value_type::iterator iterator_type; + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -1248,7 +1260,6 @@ namespace boost { namespace numeric { namespace ublas { #endif } - // Iterators simply are pointers. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator1: @@ -1947,15 +1958,16 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef const identity_matrix const_self_type; typedef identity_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else typedef const matrix_reference const_closure_type; #endif typedef matrix_reference closure_type; - typedef size_type const_iterator_type; typedef packed_tag storage_category; typedef unknown_orientation_tag orientation_category; @@ -2033,6 +2045,12 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Iterator types + private: + // Use an index + typedef size_type const_iterator_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator1 iterator1; typedef indexed_const_iterator2 iterator2; @@ -2068,7 +2086,6 @@ namespace boost { namespace numeric { namespace ublas { return const_iterator2 (*this, i, j); } - // Iterators simply are indices. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator1: @@ -2409,15 +2426,16 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef const zero_matrix const_self_type; typedef zero_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else typedef const matrix_reference const_closure_type; #endif typedef matrix_reference closure_type; - typedef size_type const_iterator_type; typedef sparse_tag storage_category; typedef unknown_orientation_tag orientation_category; @@ -2495,6 +2513,11 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Iterator types + private: + // Use an index + typedef size_type const_iterator_type; + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator1 iterator1; typedef indexed_const_iterator2 iterator2; @@ -2526,7 +2549,6 @@ namespace boost { namespace numeric { namespace ublas { return const_iterator2 (*this, i, j); } - // Iterators simply are indices. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator1: @@ -2857,14 +2879,15 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef const scalar_matrix const_self_type; typedef scalar_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else typedef const matrix_reference const_closure_type; #endif - typedef size_type const_iterator_type; typedef dense_tag storage_category; typedef unknown_orientation_tag orientation_category; @@ -2935,6 +2958,12 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Iterator types + private: + // Use an index + typedef size_type const_iterator_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator1 iterator1; typedef indexed_const_iterator2 iterator2; @@ -2962,7 +2991,6 @@ namespace boost { namespace numeric { namespace ublas { return const_iterator2 (*this, i, j); } - // Iterators simply are indices. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator1: @@ -3295,16 +3323,16 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef const c_matrix const_self_type; typedef c_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else typedef const matrix_reference const_closure_type; #endif typedef matrix_reference closure_type; - typedef const T *const_iterator_type; - typedef T *iterator_type; typedef dense_tag storage_category; // This could be better for performance, // typedef typename unknown_orientation_tag orientation_category; @@ -3523,6 +3551,13 @@ namespace boost { namespace numeric { namespace ublas { std::fill (data_ [i], data_ [i] + size2_, value_type ()); } + // Iterator types + private: + // Use pointers for iterator + typedef const T *const_iterator_type; + typedef T *iterator_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -3580,7 +3615,6 @@ namespace boost { namespace numeric { namespace ublas { #endif } - // Iterators simply are pointers. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator1: diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp index 6d155051..2e34df64 100644 --- a/include/boost/numeric/ublas/matrix_expression.hpp +++ b/include/boost/numeric/ublas/matrix_expression.hpp @@ -201,7 +201,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING matrix_expression >::operator (); #endif - typedef E expression_type; typedef typename E::size_type size_type; typedef typename E::difference_type difference_type; typedef typename E::value_type value_type; @@ -209,9 +208,10 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef typename E::const_pointer const_pointer; typedef const_pointer pointer; + private: + typedef E expression_type; + public: typedef typename E::orientation_category orientation_category; - typedef typename E::const_iterator1 const_iterator1_type; - typedef typename E::const_iterator2 const_iterator2_type; typedef typename E::storage_category storage_category; typedef typename E::simd_category simd_category; @@ -249,9 +249,10 @@ namespace boost { namespace numeric { namespace ublas { return &(*this).e_ == &mr.e_; } - typedef const_iterator1_type const_iterator1; + // Iterator types + typedef typename E::const_iterator1 const_iterator1; typedef const_iterator1 iterator1; - typedef const_iterator2_type const_iterator2; + typedef typename E::const_iterator2 const_iterator2; typedef const_iterator2 iterator2; // Element lookup @@ -344,7 +345,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING matrix_expression >::operator (); #endif - typedef E expression_type; typedef typename E::size_type size_type; typedef typename E::difference_type difference_type; typedef typename E::value_type value_type; @@ -363,26 +363,14 @@ namespace boost { namespace numeric { namespace ublas { typename E::const_pointer, typename E::pointer>::type pointer; #endif + private: + typedef E expression_type; typedef const matrix_reference const_self_type; typedef matrix_reference self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; typedef typename E::orientation_category orientation_category; -#ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS - typedef typename E::const_iterator1 const_iterator1_type; - typedef typename E::iterator1 iterator1_type; - typedef typename E::const_iterator2 const_iterator2_type; - typedef typename E::iterator2 iterator2_type; -#else - typedef typename E::const_iterator1 const_iterator1_type; - typedef typename boost::mpl::if_c::value, - typename E::const_iterator1, - typename E::iterator1>::type iterator1_type; - typedef typename E::const_iterator2 const_iterator2_type; - typedef typename boost::mpl::if_c::value, - typename E::const_iterator2, - typename E::iterator2>::type iterator2_type; -#endif typedef typename E::storage_category storage_category; typedef typename E::simd_category simd_category; @@ -491,10 +479,22 @@ namespace boost { namespace numeric { namespace ublas { return &(*this).e_ == &mr.e_; } - typedef const_iterator1_type const_iterator1; - typedef iterator1_type iterator1; - typedef const_iterator2_type const_iterator2; - typedef iterator2_type iterator2; + // Iterator types +#ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS + typedef typename E::const_iterator1 const_iterator1; + typedef typename E::iterator1 iterator1; + typedef typename E::const_iterator2 const_iterator2; + typedef typename E::iterator2 iterator2; +#else + typedef typename E::const_iterator1 const_iterator1; + typedef typename boost::mpl::if_c::value, + typename E::const_iterator1, + typename E::iterator1>::type iterator1; + typedef typename E::const_iterator2 const_iterator2; + typedef typename boost::mpl::if_c::value, + typename E::const_iterator2, + typename E::iterator2>::type iterator2; +#endif // Element lookup BOOST_UBLAS_INLINE @@ -629,8 +629,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING matrix_expression >::operator (); #endif - typedef E1 expression1_type; - typedef E2 expression2_type; typedef F functor_type; typedef typename promote_traits::promote_type size_type; typedef typename promote_traits::promote_type difference_type; @@ -639,15 +637,17 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; typedef typename E1::const_closure_type expression1_closure_type; typedef typename E2::const_closure_type expression2_closure_type; typedef const vector_matrix_binary const_self_type; typedef vector_matrix_binary self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; typedef unknown_orientation_tag orientation_category; - typedef typename E1::const_iterator const_iterator1_type; - typedef typename E2::const_iterator const_iterator2_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -689,6 +689,12 @@ namespace boost { namespace numeric { namespace ublas { (*this).expression2 ().same_closure (vmb.expression2 ()); } + // Iterator types + private: + typedef typename E1::const_iterator const_iterator1_type; + typedef typename E2::const_iterator const_iterator2_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; @@ -1148,8 +1154,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING matrix_expression >::operator (); #endif - typedef E expression_type; - typedef F functor_type; typedef typename E::size_type size_type; typedef typename E::difference_type difference_type; typedef typename F::result_type value_type; @@ -1157,14 +1161,16 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E expression_type; + typedef F functor_type; typedef typename E::const_closure_type expression_closure_type; typedef const matrix_unary1 const_self_type; typedef matrix_unary1 self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; typedef typename E::orientation_category orientation_category; - typedef typename E::const_iterator1 const_iterator1_type; - typedef typename E::const_iterator2 const_iterator2_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -1201,6 +1207,12 @@ namespace boost { namespace numeric { namespace ublas { return (*this).expression ().same_closure (mu1.expression ()); } + // Iterator types + private: + typedef typename E::const_iterator1 const_iterator1_type; + typedef typename E::const_iterator2 const_iterator2_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator1 const_iterator1; typedef const_iterator1 iterator1; @@ -1598,27 +1610,28 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING matrix_expression >::operator (); #endif - // typedef E expression_type; - typedef typename boost::mpl::if_c >::value, - E, - const E>::type expression_type; - typedef F functor_type; typedef typename E::size_type size_type; typedef typename E::difference_type difference_type; typedef typename F::result_type value_type; typedef value_type const_reference; - typedef typename boost::mpl::if_c >::value, typename E::reference, value_type>::type reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef typename boost::mpl::if_c >::value, + E, + const E>::type expression_type; + typedef F functor_type; typedef typename boost::mpl::if_c::value, typename E::const_closure_type, typename E::closure_type>::type expression_closure_type; typedef const matrix_unary2 const_self_type; typedef matrix_unary2 self_type; + public: typedef const_self_type const_closure_type; typedef self_type closure_type; // typedef typename E::orientation_category orientation_category; @@ -1629,8 +1642,6 @@ namespace boost { namespace numeric { namespace ublas { column_major_tag>::value, row_major_tag, typename E::orientation_category>::type>::type orientation_category; - typedef typename E::const_iterator1 const_iterator2_type; - typedef typename E::const_iterator2 const_iterator1_type; // typedef unknown_storage_tag storage_category; typedef typename E::storage_category storage_category; @@ -1674,6 +1685,12 @@ namespace boost { namespace numeric { namespace ublas { return (*this).expression ().same_closure (mu2.expression ()); } + // Iterator types + private: + typedef typename E::const_iterator1 const_iterator2_type; + typedef typename E::const_iterator2 const_iterator1_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator1 const_iterator1; typedef const_iterator1 iterator1; @@ -2061,9 +2078,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING matrix_expression >::operator (); #endif - typedef E1 expression1_type; - typedef E2 expression2_type; - typedef F functor_type; typedef typename promote_traits::promote_type size_type; typedef typename promote_traits::promote_type difference_type; typedef typename F::result_type value_type; @@ -2071,17 +2085,18 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; + typedef F functor_type; typedef typename E1::const_closure_type expression1_closure_type; typedef typename E2::const_closure_type expression2_closure_type; typedef const matrix_binary const_self_type; typedef matrix_binary self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; typedef unknown_orientation_tag orientation_category; - typedef typename E1::const_iterator1 const_iterator11_type; - typedef typename E1::const_iterator2 const_iterator12_type; - typedef typename E2::const_iterator1 const_iterator21_type; - typedef typename E2::const_iterator2 const_iterator22_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -2123,6 +2138,14 @@ namespace boost { namespace numeric { namespace ublas { (*this).expression2 ().same_closure (mb.expression2 ()); } + // Iterator types + private: + typedef typename E1::const_iterator1 const_iterator11_type; + typedef typename E1::const_iterator2 const_iterator12_type; + typedef typename E2::const_iterator1 const_iterator21_type; + typedef typename E2::const_iterator2 const_iterator22_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category1; @@ -2805,9 +2828,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING matrix_expression >::operator (); #endif - typedef E1 expression1_type; - typedef E2 expression2_type; - typedef F functor_type; typedef typename E2::size_type size_type; typedef typename E2::difference_type difference_type; typedef typename F::result_type value_type; @@ -2815,16 +2835,18 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; + typedef F functor_type; typedef E1 expression1_closure_type; typedef typename E2::const_closure_type expression2_closure_type; typedef const matrix_binary_scalar1 const_self_type; typedef matrix_binary_scalar1 self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; typedef typename E2::orientation_category orientation_category; - typedef typename E1::value_type const_iterator1_type; - typedef typename E2::const_iterator1 const_iterator21_type; - typedef typename E2::const_iterator2 const_iterator22_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -2866,6 +2888,13 @@ namespace boost { namespace numeric { namespace ublas { (*this).expression2 ().same_closure (mbs1.expression2 ()); } + // Iterator types + private: + typedef typename E1::value_type const_iterator1_type; + typedef typename E2::const_iterator1 const_iterator21_type; + typedef typename E2::const_iterator2 const_iterator22_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator1 const_iterator1; typedef const_iterator1 iterator1; @@ -3254,9 +3283,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING matrix_expression >::operator (); #endif - typedef E1 expression1_type; - typedef E2 expression2_type; - typedef F functor_type; typedef typename E1::size_type size_type; typedef typename E1::difference_type difference_type; typedef typename F::result_type value_type; @@ -3264,16 +3290,18 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; + typedef F functor_type; typedef typename E1::const_closure_type expression1_closure_type; typedef E2 expression2_closure_type; typedef const matrix_binary_scalar2 const_self_type; typedef matrix_binary_scalar2 self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; typedef typename E1::orientation_category orientation_category; - typedef typename E1::const_iterator1 const_iterator11_type; - typedef typename E1::const_iterator2 const_iterator12_type; - typedef typename E2::value_type const_iterator2_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -3315,6 +3343,13 @@ namespace boost { namespace numeric { namespace ublas { (*this).expression2 ().same_closure (mbs2.expression2 ()); } + // Iterator types + private: + typedef typename E1::const_iterator1 const_iterator11_type; + typedef typename E1::const_iterator2 const_iterator12_type; + typedef typename E2::value_type const_iterator2_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator1 const_iterator1; typedef const_iterator1 iterator1; @@ -3714,9 +3749,6 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_USING vector_expression >::operator (); #endif BOOST_STATIC_CONSTANT (int, complexity = 1); - typedef E1 expression1_type; - typedef E2 expression2_type; - typedef F functor_type; typedef typename promote_traits::promote_type size_type; typedef typename promote_traits::promote_type difference_type; typedef typename F::result_type value_type; @@ -3724,14 +3756,17 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; + typedef F functor_type; typedef typename E1::const_closure_type expression1_closure_type; typedef typename E2::const_closure_type expression2_closure_type; typedef const matrix_vector_binary1 const_self_type; typedef matrix_vector_binary1 self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; - typedef typename E1::const_iterator1 const_iterator1_type; - typedef typename E2::const_iterator const_iterator2_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -3769,6 +3804,12 @@ namespace boost { namespace numeric { namespace ublas { (*this).expression2 ().same_closure (mvb1.expression2 ()); } + // Iterator types + private: + typedef typename E1::const_iterator1 const_iterator1_type; + typedef typename E2::const_iterator const_iterator2_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator const_iterator; typedef const_iterator iterator; @@ -3788,7 +3829,6 @@ namespace boost { namespace numeric { namespace ublas { #endif } - // Iterator simply is a pointer. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator: @@ -4108,9 +4148,6 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_USING vector_expression >::operator (); #endif BOOST_STATIC_CONSTANT (int, complexity = 1); - typedef E1 expression1_type; - typedef E2 expression2_type; - typedef F functor_type; typedef typename promote_traits::promote_type size_type; typedef typename promote_traits::promote_type difference_type; typedef typename F::result_type value_type; @@ -4118,14 +4155,17 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; + typedef F functor_type; typedef typename E1::const_closure_type expression1_closure_type; typedef typename E2::const_closure_type expression2_closure_type; typedef const matrix_vector_binary2 const_self_type; typedef matrix_vector_binary2 self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; - typedef typename E1::const_iterator const_iterator1_type; - typedef typename E2::const_iterator2 const_iterator2_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -4164,6 +4204,12 @@ namespace boost { namespace numeric { namespace ublas { (*this).expression2 ().same_closure (mvb2.expression2 ()); } + // Iterator types + private: + typedef typename E1::const_iterator const_iterator1_type; + typedef typename E2::const_iterator2 const_iterator2_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator const_iterator; typedef const_iterator iterator; @@ -4503,9 +4549,6 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_USING matrix_expression >::operator (); #endif BOOST_STATIC_CONSTANT (int, complexity = 1); - typedef E1 expression1_type; - typedef E2 expression2_type; - typedef F functor_type; typedef typename promote_traits::promote_type size_type; typedef typename promote_traits::promote_type difference_type; typedef typename F::result_type value_type; @@ -4513,17 +4556,18 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; + typedef F functor_type; typedef typename E1::const_closure_type expression1_closure_type; typedef typename E2::const_closure_type expression2_closure_type; typedef const matrix_matrix_binary const_self_type; typedef matrix_matrix_binary self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; typedef unknown_orientation_tag orientation_category; - typedef typename E1::const_iterator1 const_iterator11_type; - typedef typename E1::const_iterator2 const_iterator12_type; - typedef typename E2::const_iterator1 const_iterator21_type; - typedef typename E2::const_iterator2 const_iterator22_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -4566,6 +4610,14 @@ namespace boost { namespace numeric { namespace ublas { (*this).expression2 ().same_closure (mmb.expression2 ()); } + // Iterator types + private: + typedef typename E1::const_iterator1 const_iterator11_type; + typedef typename E1::const_iterator2 const_iterator12_type; + typedef typename E2::const_iterator1 const_iterator21_type; + typedef typename E2::const_iterator2 const_iterator22_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; @@ -4617,7 +4669,6 @@ namespace boost { namespace numeric { namespace ublas { #endif } - // Iterators simply are pointers. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator1: diff --git a/include/boost/numeric/ublas/matrix_sparse.hpp b/include/boost/numeric/ublas/matrix_sparse.hpp index ef6a94dc..867785ec 100644 --- a/include/boost/numeric/ublas/matrix_sparse.hpp +++ b/include/boost/numeric/ublas/matrix_sparse.hpp @@ -259,19 +259,19 @@ namespace boost { namespace numeric { namespace ublas { #endif typedef const T *const_pointer; typedef T *pointer; + private: typedef F functor_type; typedef A array_type; typedef const A const_array_type; typedef const sparse_matrix const_self_type; typedef sparse_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else typedef const matrix_reference const_closure_type; #endif typedef matrix_reference closure_type; - typedef typename A::const_iterator const_iterator_type; - typedef typename A::iterator iterator_type; typedef sparse_tag storage_category; typedef typename F::orientation_category orientation_category; @@ -498,6 +498,13 @@ namespace boost { namespace numeric { namespace ublas { data ().clear (); } + // Iterator types + private: + // Use a storage iterator + typedef typename A::const_iterator const_iterator_type; + typedef typename A::iterator iterator_type; + + public: class const_iterator1; class iterator1; class const_iterator2; @@ -636,7 +643,6 @@ namespace boost { namespace numeric { namespace ublas { return iterator2 (*this, rank, i, j, it); } - // Iterators simply are pointers. class const_iterator1: public container_const_reference, @@ -1331,11 +1337,13 @@ namespace boost { namespace numeric { namespace ublas { #endif typedef const T *const_pointer; typedef T *pointer; + private: typedef A array_type; typedef const A const_array_type; typedef F functor_type; typedef const sparse_vector_of_sparse_vector const_self_type; typedef sparse_vector_of_sparse_vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else @@ -1343,10 +1351,6 @@ namespace boost { namespace numeric { namespace ublas { #endif typedef matrix_reference closure_type; typedef typename A::value_type::second_type vector_data_value_type; - typedef typename A::const_iterator vector_const_iterator_type; - typedef typename A::iterator vector_iterator_type; - typedef typename A::value_type::second_type::const_iterator const_iterator_type; - typedef typename A::value_type::second_type::iterator iterator_type; typedef sparse_tag storage_category; typedef typename F::orientation_category orientation_category; @@ -1573,6 +1577,15 @@ namespace boost { namespace numeric { namespace ublas { data_ [functor_type::size1 (size1_, size2_)] = vector_data_value_type (); } + // Iterator types + private: + // Use storage iterators + typedef typename A::const_iterator vector_const_iterator_type; + typedef typename A::iterator vector_iterator_type; + typedef typename A::value_type::second_type::const_iterator const_iterator_type; + typedef typename A::value_type::second_type::iterator iterator_type; + + public: class const_iterator1; class iterator1; class const_iterator2; @@ -1747,7 +1760,6 @@ namespace boost { namespace numeric { namespace ublas { } } - // Iterators simply are pointers. class const_iterator1: public container_const_reference, @@ -2513,21 +2525,19 @@ namespace boost { namespace numeric { namespace ublas { #endif typedef const T *const_pointer; typedef T *pointer; + private: typedef IA index_array_type; typedef TA value_array_type; typedef F functor_type; typedef const compressed_matrix const_self_type; typedef compressed_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else typedef const matrix_reference const_closure_type; #endif typedef matrix_reference closure_type; - typedef typename IA::const_iterator vector_const_iterator_type; - typedef typename IA::iterator vector_iterator_type; - typedef typename IA::const_iterator const_iterator_type; - typedef typename IA::iterator iterator_type; typedef sparse_tag storage_category; typedef typename F::orientation_category orientation_category; @@ -2930,6 +2940,15 @@ namespace boost { namespace numeric { namespace ublas { index1_data_ [filled1_ - 1] = k_based (filled2_); } + // Iterator types + private: + // Use index array iterator + typedef typename IA::const_iterator vector_const_iterator_type; + typedef typename IA::iterator vector_iterator_type; + typedef typename IA::const_iterator const_iterator_type; + typedef typename IA::iterator iterator_type; + + public: class const_iterator1; class iterator1; class const_iterator2; @@ -3112,7 +3131,6 @@ namespace boost { namespace numeric { namespace ublas { } } - // Iterators simply are pointers. class const_iterator1: public container_const_reference, @@ -3844,21 +3862,19 @@ namespace boost { namespace numeric { namespace ublas { #endif typedef const T *const_pointer; typedef T *pointer; + private: typedef IA index_array_type; typedef TA value_array_type; typedef F functor_type; typedef const coordinate_matrix const_self_type; typedef coordinate_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else typedef const matrix_reference const_closure_type; #endif typedef matrix_reference closure_type; - typedef typename IA::const_iterator vector_const_iterator_type; - typedef typename IA::iterator vector_iterator_type; - typedef typename IA::const_iterator const_iterator_type; - typedef typename IA::iterator iterator_type; typedef sparse_tag storage_category; typedef typename F::orientation_category orientation_category; @@ -4232,6 +4248,15 @@ namespace boost { namespace numeric { namespace ublas { filled_ = 0; } + // Iterator types + private: + // Use index array iterator + typedef typename IA::const_iterator vector_const_iterator_type; + typedef typename IA::iterator vector_iterator_type; + typedef typename IA::const_iterator const_iterator_type; + typedef typename IA::iterator iterator_type; + + public: class const_iterator1; class iterator1; class const_iterator2; @@ -4418,7 +4443,6 @@ namespace boost { namespace numeric { namespace ublas { } } - // Iterators simply are pointers. class const_iterator1: public container_const_reference, diff --git a/include/boost/numeric/ublas/storage.hpp b/include/boost/numeric/ublas/storage.hpp index 7b64812a..3d223a70 100644 --- a/include/boost/numeric/ublas/storage.hpp +++ b/include/boost/numeric/ublas/storage.hpp @@ -921,7 +921,6 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; // DEPRECATED typedef const value_type *const_pointer; // DEPRECATED typedef value_type *pointer; - typedef size_type const_iterator_type; // Construction and destruction BOOST_UBLAS_INLINE @@ -965,8 +964,12 @@ namespace boost { namespace numeric { namespace ublas { return ! (*this == r); } - // Iterator simply is a index. + // Iterator types + private: + // Use and index + typedef size_type const_iterator_type; + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator const_iterator; #else @@ -1116,7 +1119,6 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; // DEPRECATED typedef const value_type *const_pointer; // DEPRECATED typedef value_type *pointer; - typedef size_type const_iterator_type; // Construction and destruction BOOST_UBLAS_INLINE @@ -1169,8 +1171,12 @@ namespace boost { namespace numeric { namespace ublas { return ! (*this == s); } - // Iterator simply is a index. + // Iterator types + private: + // Use and index + typedef size_type const_iterator_type; + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator const_iterator; #else @@ -1322,7 +1328,6 @@ namespace boost { namespace numeric { namespace ublas { typedef typename A::reference reference; typedef typename A::const_pointer const_pointer; typedef typename A::pointer pointer; - typedef difference_type const_iterator_type; // Construction and destruction BOOST_UBLAS_INLINE @@ -1418,8 +1423,12 @@ namespace boost { namespace numeric { namespace ublas { return ! (*this == ia); } - // Iterator simply is a index. + // Iterator types + private: + // Use a index difference + typedef difference_type const_iterator_type; + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator const_iterator; #else diff --git a/include/boost/numeric/ublas/vector.hpp b/include/boost/numeric/ublas/vector.hpp index e379a177..56d15e7e 100644 --- a/include/boost/numeric/ublas/vector.hpp +++ b/include/boost/numeric/ublas/vector.hpp @@ -88,18 +88,18 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef A array_type; typedef const A const_array_type; typedef const vector const_self_type; typedef vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const vector_const_reference const_closure_type; #else typedef const vector_reference const_closure_type; #endif typedef vector_reference closure_type; - typedef typename A::const_iterator const_iterator_type; - typedef typename A::iterator iterator_type; typedef dense_tag storage_category; typedef concrete_tag simd_category; @@ -290,6 +290,13 @@ namespace boost { namespace numeric { namespace ublas { std::fill (data ().begin (), data ().end (), value_type ()); } + // Iterator types + private: + // Use the storage array iterator + typedef typename A::const_iterator const_iterator_type; + typedef typename A::iterator iterator_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator iterator; typedef indexed_const_iterator const_iterator; @@ -316,7 +323,6 @@ namespace boost { namespace numeric { namespace ublas { #endif } - // Iterators simply are pointers. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator: @@ -610,15 +616,16 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef const unit_vector const_self_type; typedef unit_vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const vector_const_reference const_closure_type; #else typedef const vector_reference const_closure_type; #endif typedef vector_reference closure_type; - typedef size_type const_iterator_type; typedef packed_tag storage_category; // Construction and destruction @@ -690,6 +697,11 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Iterator types + private: + // Use an index + typedef size_type const_iterator_type; + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator iterator; typedef indexed_const_iterator const_iterator; @@ -705,8 +717,6 @@ namespace boost { namespace numeric { namespace ublas { return const_iterator (*this, i); } - // Iterators simply are pointers. - #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator: public container_const_reference, @@ -854,15 +864,16 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef const zero_vector const_self_type; typedef zero_vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const vector_const_reference const_closure_type; #else typedef const vector_reference const_closure_type; #endif typedef vector_reference closure_type; - typedef size_type const_iterator_type; typedef sparse_tag storage_category; // Construction and destruction @@ -928,6 +939,11 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Iterator types + private: + // Use an index + typedef size_type const_iterator_type; + public: class const_iterator; // Element lookup @@ -936,7 +952,6 @@ namespace boost { namespace numeric { namespace ublas { return const_iterator (*this, i); } - // Iterators simply are pointers. class const_iterator: public container_const_reference, @@ -1058,14 +1073,15 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef const scalar_vector const_self_type; typedef scalar_vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const vector_const_reference const_closure_type; #else typedef const vector_reference const_closure_type; #endif - typedef size_type const_iterator_type; typedef dense_tag storage_category; // Construction and destruction @@ -1133,6 +1149,12 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Iterator types + private: + // Use an index + typedef size_type const_iterator_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator iterator; typedef indexed_const_iterator const_iterator; @@ -1146,7 +1168,6 @@ namespace boost { namespace numeric { namespace ublas { return const_iterator (*this, i); } - // Iterators simply are pointers. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator: @@ -1286,16 +1307,16 @@ namespace boost { namespace numeric { namespace ublas { typedef T &reference; typedef const T *const_pointer; typedef T *pointer; + private: typedef const c_vector const_self_type; typedef c_vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const vector_const_reference const_closure_type; #else typedef const vector_reference const_closure_type; #endif typedef vector_reference closure_type; - typedef const T *const_iterator_type; - typedef T *iterator_type; typedef dense_tag storage_category; typedef concrete_tag simd_category; @@ -1487,6 +1508,13 @@ namespace boost { namespace numeric { namespace ublas { std::fill (data_, data_ + size_, value_type ()); } + // Iterator types + private: + // Use pointers for iterator + typedef const T *const_iterator_type; + typedef T *iterator_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator iterator; typedef indexed_const_iterator const_iterator; @@ -1513,7 +1541,6 @@ namespace boost { namespace numeric { namespace ublas { #endif } - // Iterators simply are pointers. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator: diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index cdbdbf04..22d03bd8 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -196,7 +196,6 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef typename E::const_pointer const_pointer; typedef const_pointer pointer; - typedef typename E::const_iterator const_iterator_type; typedef typename E::storage_category storage_category; typedef typename E::simd_category simd_category; @@ -235,15 +234,16 @@ namespace boost { namespace numeric { namespace ublas { return &(*this).e_ == &vr.e_; } - typedef const_iterator_type const_iterator; - typedef const_iterator iterator; - // Element lookup BOOST_UBLAS_INLINE const_iterator find (size_type i) const { return expression ().find (i); } + // Iterator types + typedef typename E::const_iterator const_iterator; + typedef const_iterator iterator; + // Iterator is the iterator of the referenced expression. BOOST_UBLAS_INLINE @@ -294,7 +294,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING vector_expression >::operator (); #endif - typedef E expression_type; typedef typename E::size_type size_type; typedef typename E::difference_type difference_type; typedef typename E::value_type value_type; @@ -313,19 +312,13 @@ namespace boost { namespace numeric { namespace ublas { typename E::const_pointer, typename E::pointer>::type pointer; #endif + private: + typedef E expression_type; typedef const vector_reference const_self_type; typedef vector_reference self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; -#ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS - typedef typename E::const_iterator const_iterator_type; - typedef typename E::iterator iterator_type; -#else - typedef typename E::const_iterator const_iterator_type; - typedef typename boost::mpl::if_c::value, - typename E::const_iterator, - typename E::iterator>::type iterator_type; -#endif typedef typename E::storage_category storage_category; typedef typename E::simd_category simd_category; @@ -444,8 +437,16 @@ namespace boost { namespace numeric { namespace ublas { return &(*this).e_ == &vr.e_; } - typedef const_iterator_type const_iterator; - typedef iterator_type iterator; + // Iterator types +#ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS + typedef typename E::const_iterator const_iterator; + typedef typename E::iterator iterator; +#else + typedef typename E::const_iterator const_iterator; + typedef typename boost::mpl::if_c::value, + typename E::const_iterator, + typename E::iterator>::type iterator; +#endif // Element lookup BOOST_UBLAS_INLINE @@ -524,30 +525,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING vector_expression >::operator (); #endif - // typedef E expression_type; typedef typename boost::mpl::if_c >::value, E, const E>::type expression_type; - typedef F functor_type; typedef typename E::size_type size_type; typedef typename E::difference_type difference_type; typedef typename F::result_type value_type; typedef value_type const_reference; - typedef typename boost::mpl::if_c >::value, typename E::reference, value_type>::type reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef F functor_type; typedef typename boost::mpl::if_c::value, typename E::const_closure_type, typename E::closure_type>::type expression_closure_type; typedef const vector_unary const_self_type; typedef vector_unary self_type; + public: typedef const_self_type const_closure_type; typedef self_type closure_type; - typedef typename E::const_iterator const_iterator_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -596,6 +597,11 @@ namespace boost { namespace numeric { namespace ublas { return (*this).expression ().same_closure (vu.expression ()); } + // Iterator types + private: + typedef typename E::const_iterator const_iterator_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator const_iterator; typedef const_iterator iterator; @@ -820,9 +826,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING vector_expression >::operator (); #endif - typedef E1 expression1_type; - typedef E2 expression2_type; - typedef F functor_type; typedef typename promote_traits::promote_type size_type; typedef typename promote_traits::promote_type difference_type; typedef typename F::result_type value_type; @@ -830,14 +833,17 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; + typedef F functor_type; typedef typename E1::const_closure_type expression1_closure_type; typedef typename E2::const_closure_type expression2_closure_type; typedef const vector_binary const_self_type; typedef vector_binary self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; - typedef typename E1::const_iterator const_iterator1_type; - typedef typename E2::const_iterator const_iterator2_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -880,6 +886,11 @@ namespace boost { namespace numeric { namespace ublas { (*this).expression2 ().same_closure (vb.expression2 ()); } + // Iterator types + private: + typedef typename E1::const_iterator const_iterator1_type; + typedef typename E2::const_iterator const_iterator2_type; + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; @@ -1209,9 +1220,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING vector_expression >::operator (); #endif - typedef E1 expression1_type; - typedef E2 expression2_type; - typedef F functor_type; typedef typename E2::size_type size_type; typedef typename E2::difference_type difference_type; typedef typename F::result_type value_type; @@ -1219,14 +1227,17 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; + typedef F functor_type; typedef E1 expression1_closure_type; typedef typename E2::const_closure_type expression2_closure_type; typedef const vector_binary_scalar1 const_self_type; typedef vector_binary_scalar1 self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; - typedef typename E1::value_type const_iterator1_type; - typedef typename E2::const_iterator const_iterator2_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -1269,6 +1280,12 @@ namespace boost { namespace numeric { namespace ublas { (*this).expression2 ().same_closure (vbs1.expression2 ()); } + // Iterator types + private: + typedef typename E1::value_type const_iterator1_type; + typedef typename E2::const_iterator const_iterator2_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator const_iterator; typedef const_iterator iterator; @@ -1450,9 +1467,6 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING vector_expression >::operator (); #endif - typedef E1 expression1_type; - typedef E2 expression2_type; - typedef F functor_type; typedef typename E1::size_type size_type; typedef typename E1::difference_type difference_type; typedef typename F::result_type value_type; @@ -1460,14 +1474,17 @@ namespace boost { namespace numeric { namespace ublas { typedef const_reference reference; typedef const value_type *const_pointer; typedef const_pointer pointer; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; + typedef F functor_type; typedef typename E1::const_closure_type expression1_closure_type; typedef E2 expression2_closure_type; typedef const vector_binary_scalar2 const_self_type; typedef vector_binary_scalar2 self_type; + public: typedef const_self_type const_closure_type; typedef const_closure_type closure_type; - typedef typename E1::const_iterator const_iterator1_type; - typedef typename E2::value_type const_iterator2_type; typedef unknown_storage_tag storage_category; // Construction and destruction @@ -1510,6 +1527,12 @@ namespace boost { namespace numeric { namespace ublas { (*this).expression2 ().same_closure (vbs2.expression2 ()); } + // Iterator types + private: + typedef typename E1::const_iterator const_iterator1_type; + typedef typename E2::value_type const_iterator2_type; + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_const_iterator const_iterator; typedef const_iterator iterator; @@ -1698,13 +1721,15 @@ namespace boost { namespace numeric { namespace ublas { class vector_scalar_unary: public scalar_expression { public: - typedef E expression_type; - typedef F functor_type; typedef typename F::size_type size_type; typedef typename F::difference_type difference_type; typedef typename F::result_type value_type; + private: + typedef E expression_type; + typedef F functor_type; typedef typename E::const_closure_type expression_closure_type; typedef typename E::const_iterator::iterator_category iterator_category; + public: typedef unknown_storage_tag storage_category; // Construction and destruction @@ -1824,16 +1849,18 @@ namespace boost { namespace numeric { namespace ublas { public scalar_expression { public: BOOST_STATIC_CONSTANT (int, complexity = 1); - typedef E1 expression1_type; - typedef E2 expression2_type; - typedef F functor_type; typedef typename F::size_type size_type; typedef typename F::difference_type difference_type; typedef typename F::result_type value_type; + private: + typedef E1 expression1_type; + typedef E2 expression2_type; + typedef F functor_type; typedef typename E1::const_closure_type expression1_closure_type; typedef typename E2::const_closure_type expression2_closure_type; typedef typename iterator_restrict_traits::iterator_category iterator_category; + public: typedef unknown_storage_tag storage_category; // Construction and destruction diff --git a/include/boost/numeric/ublas/vector_of_vector.hpp b/include/boost/numeric/ublas/vector_of_vector.hpp index fa8e45c0..fa673a2a 100644 --- a/include/boost/numeric/ublas/vector_of_vector.hpp +++ b/include/boost/numeric/ublas/vector_of_vector.hpp @@ -44,11 +44,13 @@ namespace boost { namespace numeric { namespace ublas { #endif typedef const T *const_pointer; typedef T *pointer; + private: typedef A array_type; typedef const A const_array_type; typedef F functor_type; typedef const generalized_vector_of_vector const_self_type; typedef generalized_vector_of_vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else @@ -56,10 +58,6 @@ namespace boost { namespace numeric { namespace ublas { #endif typedef matrix_reference closure_type; typedef typename A::value_type vector_data_value_type; - typedef typename A::const_iterator vector_const_iterator_type; - typedef typename A::iterator vector_iterator_type; - typedef typename A::value_type::const_iterator const_iterator_type; - typedef typename A::value_type::iterator iterator_type; typedef sparse_tag storage_category; typedef typename F::orientation_category orientation_category; @@ -302,6 +300,15 @@ namespace boost { namespace numeric { namespace ublas { data_ [functor_type::size1 (size1_, size2_)] = vector_data_value_type (); } + // Iterator types + private: + // Use vector iterator + typedef typename A::const_iterator vector_const_iterator_type; + typedef typename A::iterator vector_iterator_type; + typedef typename A::value_type::const_iterator const_iterator_type; + typedef typename A::value_type::iterator iterator_type; + + public: class const_iterator1; class iterator1; class const_iterator2; @@ -476,7 +483,6 @@ namespace boost { namespace numeric { namespace ublas { } } - // Iterators simply are pointers. class const_iterator1: public container_const_reference, diff --git a/include/boost/numeric/ublas/vector_sparse.hpp b/include/boost/numeric/ublas/vector_sparse.hpp index ec4c0d22..58b0a98c 100644 --- a/include/boost/numeric/ublas/vector_sparse.hpp +++ b/include/boost/numeric/ublas/vector_sparse.hpp @@ -255,18 +255,18 @@ namespace boost { namespace numeric { namespace ublas { #endif typedef const T *const_pointer; typedef T *pointer; + private: typedef A array_type; typedef const A const_array_type; typedef const sparse_vector const_self_type; typedef sparse_vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const vector_const_reference const_closure_type; #else typedef const vector_reference const_closure_type; #endif typedef vector_reference closure_type; - typedef typename A::const_iterator const_iterator_type; - typedef typename A::iterator iterator_type; typedef sparse_tag storage_category; // Construction and destruction @@ -488,6 +488,13 @@ namespace boost { namespace numeric { namespace ublas { data ().clear (); } + // Iterator types + private: + // Use storage iterator + typedef typename A::const_iterator const_iterator_type; + typedef typename A::iterator iterator_type; + + public: class const_iterator; class iterator; @@ -503,7 +510,6 @@ namespace boost { namespace numeric { namespace ublas { return iterator (*this, data ().lower_bound (i)); } - // Iterators simply are pointers. class const_iterator: public container_const_reference, @@ -738,18 +744,18 @@ namespace boost { namespace numeric { namespace ublas { #endif typedef const T *const_pointer; typedef T *pointer; + private: typedef IA index_array_type; typedef TA value_array_type; typedef const compressed_vector const_self_type; typedef compressed_vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const vector_const_reference const_closure_type; #else typedef const vector_reference const_closure_type; #endif typedef vector_reference closure_type; - typedef typename IA::const_iterator const_iterator_type; - typedef typename IA::iterator iterator_type; typedef sparse_tag storage_category; // Construction and destruction @@ -1034,6 +1040,13 @@ namespace boost { namespace numeric { namespace ublas { filled_ = 0; } + // Iterator types + private: + // Use index array iterator + typedef typename IA::const_iterator const_iterator_type; + typedef typename IA::iterator iterator_type; + + public: class const_iterator; class iterator; @@ -1049,7 +1062,6 @@ namespace boost { namespace numeric { namespace ublas { return iterator (*this, detail::lower_bound (index_data ().begin (), index_data ().begin () + filled_, k_based (i), std::less ())); } - // Iterators simply are pointers. class const_iterator: public container_const_reference, @@ -1296,18 +1308,18 @@ namespace boost { namespace numeric { namespace ublas { #endif typedef const T *const_pointer; typedef T *pointer; + private: typedef IA index_array_type; typedef TA value_array_type; typedef const coordinate_vector const_self_type; typedef coordinate_vector self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const vector_const_reference const_closure_type; #else typedef const vector_reference const_closure_type; #endif typedef vector_reference closure_type; - typedef typename IA::const_iterator const_iterator_type; - typedef typename IA::iterator iterator_type; typedef sparse_tag storage_category; // Construction and destruction @@ -1620,6 +1632,13 @@ namespace boost { namespace numeric { namespace ublas { filled_ = 0; } + // Iterator types + private: + // Use index array iterator + typedef typename IA::const_iterator const_iterator_type; + typedef typename IA::iterator iterator_type; + + public: class const_iterator; class iterator; @@ -1637,7 +1656,6 @@ namespace boost { namespace numeric { namespace ublas { return iterator (*this, detail::lower_bound (index_data ().begin (), index_data ().begin () + filled_, k_based (i), std::less ())); } - // Iterators simply are pointers. class const_iterator: public container_const_reference,