1 /** 2 * -*- c++ -*- 3 * 4 * \file iterator_type.hpp 5 * 6 * \brief 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_ITERATOR_TYPE_HPP 19 #define BOOST_NUMERIC_UBLAS_TRAITS_ITERATOR_TYPE_HPP 20 21 22 #include <boost/numeric/ublas/fwd.hpp> 23 #include <boost/numeric/ublas/traits.hpp> 24 #include <boost/numeric/ublas/tags.hpp> 25 26 27 namespace boost { namespace numeric { namespace ublas { 28 29 namespace detail { 30 31 /** 32 * \brief Auxiliary class for retrieving the 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 iterator_type_impl; 40 41 42 /// \brief Specialization of \c iterator_type_impl for row-major oriented 43 /// matrices and over the major dimension. 44 template <typename MatrixT> 45 struct iterator_type_impl<MatrixT,tag::major,row_major_tag> 46 { 47 typedef typename matrix_traits<MatrixT>::iterator1 type; 48 }; 49 50 51 /// \brief Specialization of \c iterator_type_impl for column-major oriented 52 /// matrices and over the major dimension. 53 template <typename MatrixT> 54 struct iterator_type_impl<MatrixT,tag::major,column_major_tag> 55 { 56 typedef typename matrix_traits<MatrixT>::iterator2 type; 57 }; 58 59 60 /// \brief Specialization of \c iterator_type_impl for row-major oriented 61 /// matrices and over the minor dimension. 62 template <typename MatrixT> 63 struct iterator_type_impl<MatrixT,tag::minor,row_major_tag> 64 { 65 typedef typename matrix_traits<MatrixT>::iterator2 type; 66 }; 67 68 69 /// \brief Specialization of \c iterator_type_impl for column-major oriented 70 /// matrices and over the minor dimension. 71 template <typename MatrixT> 72 struct iterator_type_impl<MatrixT,tag::minor,column_major_tag> 73 { 74 typedef typename matrix_traits<MatrixT>::iterator1 type; 75 }; 76 77 } // Namespace detail 78 79 80 /** 81 * \brief A iterator for the given container type over the given dimension. 82 * \tparam ContainerT A container expression type. 83 * \tparam TagT A dimension tag type (e.g., tag::major). 84 */ 85 template <typename ContainerT, typename TagT=void> 86 struct iterator_type; 87 88 89 /** 90 * \brief Specialization of \c iterator_type for vector expressions. 91 * \tparam VectorT A model of VectorExpression type. 92 */ 93 template <typename VectorT> 94 struct iterator_type<VectorT, void> 95 { 96 typedef typename vector_traits<VectorT>::iterator type; 97 }; 98 99 100 /** 101 * \brief Specialization of \c iterator_type for matrix expressions and 102 * over the major dimension. 103 * \tparam MatrixT A model of MatrixExpression type. 104 */ 105 template <typename MatrixT> 106 struct iterator_type<MatrixT,tag::major> 107 { 108 typedef typename detail::iterator_type_impl<MatrixT,tag::major,typename matrix_traits<MatrixT>::orientation_category>::type type; 109 }; 110 111 112 /** 113 * \brief Specialization of \c iterator_type for matrix expressions and 114 * over the minor dimension. 115 * \tparam MatrixT A model of MatrixExpression type. 116 */ 117 template <typename MatrixT> 118 struct iterator_type<MatrixT,tag::minor> 119 { 120 typedef typename detail::iterator_type_impl<MatrixT,tag::minor,typename matrix_traits<MatrixT>::orientation_category>::type type; 121 }; 122 123 }}} // Namespace boost::numeric::ublas 124 125 126 #endif // BOOST_NUMERIC_UBLAS_TRAITS_ITERATOR_TYPE_HPP 127