1 /** 2 * -*- c++ -*- 3 * 4 * \file const_iterator_type.hpp 5 * 6 * \brief Const iterator to a given container type. 7 * 8 * Copyright (c) 2009, Marco Guazzone 9 * 10 * Distributed under the Boost Software License, Version 1.0. (See 11 * accompanying file LICENSE_1_0.txt or copy at 12 * http://www.boost.org/LICENSE_1_0.txt) 13 * 14 * \author Marco Guazzone, marco.guazzone@gmail.com 15 */ 16 17 18 #ifndef BOOST_NUMERIC_UBLAS_TRAITS_CONST_ITERATOR_TYPE_HPP 19 #define BOOST_NUMERIC_UBLAS_TRAITS_CONST_ITERATOR_TYPE_HPP 20 21 22 #include <boost/numeric/ublas/fwd.hpp> 23 #include <boost/numeric/ublas/tags.hpp> 24 #include <boost/numeric/ublas/traits.hpp> 25 26 27 namespace boost { namespace numeric { namespace ublas { 28 29 namespace detail { 30 31 /** 32 * \brief Auxiliary class for retrieving the const iterator to the given 33 * matrix expression according its orientation and to the given dimension tag. 34 * \tparam MatrixT A model of MatrixExpression. 35 * \tparam TagT A dimension tag type (e.g., tag::major). 36 * \tparam OrientationT An orientation category type (e.g., row_major_tag). 37 */ 38 template <typename MatrixT, typename TagT, typename OrientationT> 39 struct const_iterator_type_impl; 40 41 42 /// \brief Specialization of \c const_iterator_type_impl for row-major oriented 43 /// matrices and over the major dimension. 44 template <typename MatrixT> 45 struct const_iterator_type_impl<MatrixT,tag::major,row_major_tag> 46 { 47 typedef typename matrix_view_traits<MatrixT>::const_iterator1 type; 48 }; 49 50 51 /// \brief Specialization of \c const_iterator_type_impl for column-major 52 /// oriented matrices and over the major dimension. 53 template <typename MatrixT> 54 struct const_iterator_type_impl<MatrixT,tag::major,column_major_tag> 55 { 56 typedef typename matrix_view_traits<MatrixT>::const_iterator2 type; 57 }; 58 59 60 /// \brief Specialization of \c const_iterator_type_impl for row-major oriented 61 /// matrices and over the minor dimension. 62 template <typename MatrixT> 63 struct const_iterator_type_impl<MatrixT,tag::minor,row_major_tag> 64 { 65 typedef typename matrix_view_traits<MatrixT>::const_iterator2 type; 66 }; 67 68 69 /// \brief Specialization of \c const_iterator_type_impl for column-major 70 /// oriented matrices and over the minor dimension. 71 template <typename MatrixT> 72 struct const_iterator_type_impl<MatrixT,tag::minor,column_major_tag> 73 { 74 typedef typename matrix_view_traits<MatrixT>::const_iterator1 type; 75 }; 76 77 } // Namespace detail 78 79 80 /** 81 * \brief A const iterator for the given container type over the given 82 * dimension. 83 * \tparam ContainerT A container expression type. 84 * \tparam TagT A dimension tag type (e.g., tag::major). 85 */ 86 template <typename ContainerT, typename TagT=void> 87 struct const_iterator_type; 88 89 90 /** 91 * \brief Specialization of \c const_iterator_type for vector expressions. 92 * \tparam VectorT A model of VectorExpression type. 93 */ 94 template <typename VectorT> 95 struct const_iterator_type<VectorT, void> 96 { 97 typedef typename vector_view_traits<VectorT>::const_iterator type; 98 }; 99 100 101 /** 102 * \brief Specialization of \c const_iterator_type for matrix expressions and 103 * over the major dimension. 104 * \tparam MatrixT A model of MatrixExpression type. 105 */ 106 template <typename MatrixT> 107 struct const_iterator_type<MatrixT,tag::major> 108 { 109 typedef typename detail::const_iterator_type_impl<MatrixT,tag::minor,typename matrix_view_traits<MatrixT>::orientation_category>::type type; 110 }; 111 112 113 /** 114 * \brief Specialization of \c const_iterator_type for matrix expressions and 115 * over the minor dimension. 116 * \tparam MatrixT A model of MatrixExpression type. 117 */ 118 template <typename MatrixT> 119 struct const_iterator_type<MatrixT,tag::minor> 120 { 121 typedef typename detail::const_iterator_type_impl<MatrixT,tag::minor,typename matrix_view_traits<MatrixT>::orientation_category>::type type; 122 }; 123 124 }}} // Namespace boost::numeric::ublas 125 126 127 #endif // BOOST_NUMERIC_UBLAS_TRAITS_CONST_ITERATOR_TYPE_HPP 128