const_iterator_type.hpp 4.2 KB

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