iterator_type.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #ifndef BOOST_NUMERIC_UBLAS_TRAITS_ITERATOR_TYPE_HPP
  17. #define BOOST_NUMERIC_UBLAS_TRAITS_ITERATOR_TYPE_HPP
  18. #include <boost/numeric/ublas/fwd.hpp>
  19. #include <boost/numeric/ublas/traits.hpp>
  20. #include <boost/numeric/ublas/tags.hpp>
  21. namespace boost { namespace numeric { namespace ublas {
  22. namespace detail {
  23. /**
  24. * \brief Auxiliary class for retrieving the iterator to the given
  25. * matrix expression according its orientation and to the given dimension tag.
  26. * \tparam MatrixT A model of MatrixExpression.
  27. * \tparam TagT A dimension tag type (e.g., tag::major).
  28. * \tparam OrientationT An orientation category type (e.g., row_major_tag).
  29. */
  30. template <typename MatrixT, typename TagT, typename OrientationT>
  31. struct iterator_type_impl;
  32. /// \brief Specialization of \c iterator_type_impl for row-major oriented
  33. /// matrices and over the major dimension.
  34. template <typename MatrixT>
  35. struct iterator_type_impl<MatrixT,tag::major,row_major_tag>
  36. {
  37. typedef typename matrix_traits<MatrixT>::iterator1 type;
  38. };
  39. /// \brief Specialization of \c iterator_type_impl for column-major oriented
  40. /// matrices and over the major dimension.
  41. template <typename MatrixT>
  42. struct iterator_type_impl<MatrixT,tag::major,column_major_tag>
  43. {
  44. typedef typename matrix_traits<MatrixT>::iterator2 type;
  45. };
  46. /// \brief Specialization of \c iterator_type_impl for row-major oriented
  47. /// matrices and over the minor dimension.
  48. template <typename MatrixT>
  49. struct iterator_type_impl<MatrixT,tag::minor,row_major_tag>
  50. {
  51. typedef typename matrix_traits<MatrixT>::iterator2 type;
  52. };
  53. /// \brief Specialization of \c iterator_type_impl for column-major oriented
  54. /// matrices and over the minor dimension.
  55. template <typename MatrixT>
  56. struct iterator_type_impl<MatrixT,tag::minor,column_major_tag>
  57. {
  58. typedef typename matrix_traits<MatrixT>::iterator1 type;
  59. };
  60. } // Namespace detail
  61. /**
  62. * \brief A iterator for the given container type over the given dimension.
  63. * \tparam ContainerT A container expression type.
  64. * \tparam TagT A dimension tag type (e.g., tag::major).
  65. */
  66. template <typename ContainerT, typename TagT=void>
  67. struct iterator_type;
  68. /**
  69. * \brief Specialization of \c iterator_type for vector expressions.
  70. * \tparam VectorT A model of VectorExpression type.
  71. */
  72. template <typename VectorT>
  73. struct iterator_type<VectorT, void>
  74. {
  75. typedef typename vector_traits<VectorT>::iterator type;
  76. };
  77. /**
  78. * \brief Specialization of \c iterator_type for matrix expressions and
  79. * over the major dimension.
  80. * \tparam MatrixT A model of MatrixExpression type.
  81. */
  82. template <typename MatrixT>
  83. struct iterator_type<MatrixT,tag::major>
  84. {
  85. typedef typename detail::iterator_type_impl<MatrixT,tag::major,typename matrix_traits<MatrixT>::orientation_category>::type type;
  86. };
  87. /**
  88. * \brief Specialization of \c iterator_type for matrix expressions and
  89. * over the minor dimension.
  90. * \tparam MatrixT A model of MatrixExpression type.
  91. */
  92. template <typename MatrixT>
  93. struct iterator_type<MatrixT,tag::minor>
  94. {
  95. typedef typename detail::iterator_type_impl<MatrixT,tag::minor,typename matrix_traits<MatrixT>::orientation_category>::type type;
  96. };
  97. }}} // Namespace boost::numeric::ublas
  98. #endif // BOOST_NUMERIC_UBLAS_TRAITS_ITERATOR_TYPE_HPP