mpl_common.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #ifndef BOOST_MP11_DETAIL_MPL_COMMON_HPP_INCLUDED
  2. #define BOOST_MP11_DETAIL_MPL_COMMON_HPP_INCLUDED
  3. // Copyright 2017, 2019 Peter Dimov.
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. //
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. #include <boost/mp11/list.hpp>
  10. #include <boost/mp11/algorithm.hpp>
  11. namespace boost
  12. {
  13. namespace mpl
  14. {
  15. struct forward_iterator_tag;
  16. namespace aux
  17. {
  18. struct mp11_tag {};
  19. template<class L> struct mp11_iterator
  20. {
  21. using category = forward_iterator_tag;
  22. using type = mp11::mp_first<L>;
  23. using next = mp11_iterator<mp11::mp_rest<L>>;
  24. };
  25. } // namespace aux
  26. // at
  27. template< typename Tag > struct at_impl;
  28. template<> struct at_impl<aux::mp11_tag>
  29. {
  30. template<class L, class I> struct apply
  31. {
  32. using type = mp11::mp_at<L, I>;
  33. };
  34. };
  35. // back
  36. template< typename Tag > struct back_impl;
  37. template<> struct back_impl<aux::mp11_tag>
  38. {
  39. template<class L> struct apply
  40. {
  41. using N = mp11::mp_size<L>;
  42. using type = mp11::mp_at_c<L, N::value - 1>;
  43. };
  44. };
  45. // begin
  46. template< typename Tag > struct begin_impl;
  47. template<> struct begin_impl<aux::mp11_tag>
  48. {
  49. template<class L> struct apply
  50. {
  51. using type = aux::mp11_iterator<L>;
  52. };
  53. };
  54. // clear
  55. template< typename Tag > struct clear_impl;
  56. template<> struct clear_impl<aux::mp11_tag>
  57. {
  58. template<class L> struct apply
  59. {
  60. using type = mp11::mp_clear<L>;
  61. };
  62. };
  63. // end
  64. template< typename Tag > struct end_impl;
  65. template<> struct end_impl<aux::mp11_tag>
  66. {
  67. template<class L> struct apply
  68. {
  69. using type = aux::mp11_iterator<mp11::mp_clear<L>>;
  70. };
  71. };
  72. // front
  73. template< typename Tag > struct front_impl;
  74. template<> struct front_impl<aux::mp11_tag>
  75. {
  76. template<class L> struct apply
  77. {
  78. using type = mp11::mp_front<L>;
  79. };
  80. };
  81. // pop_front
  82. template< typename Tag > struct pop_front_impl;
  83. template<> struct pop_front_impl<aux::mp11_tag>
  84. {
  85. template<class L> struct apply
  86. {
  87. using type = mp11::mp_pop_front<L>;
  88. };
  89. };
  90. // push_back
  91. template< typename Tag > struct push_back_impl;
  92. template<> struct push_back_impl<aux::mp11_tag>
  93. {
  94. template<class L, class T> struct apply
  95. {
  96. using type = mp11::mp_push_back<L, T>;
  97. };
  98. };
  99. // push_front
  100. template< typename Tag > struct push_front_impl;
  101. template<> struct push_front_impl<aux::mp11_tag>
  102. {
  103. template<class L, class T> struct apply
  104. {
  105. using type = mp11::mp_push_front<L, T>;
  106. };
  107. };
  108. // size
  109. template< typename Tag > struct size_impl;
  110. template<> struct size_impl<aux::mp11_tag>
  111. {
  112. template<class L> struct apply
  113. {
  114. using type = mp11::mp_size<L>;
  115. };
  116. };
  117. } // namespace mpl
  118. } // namespace boost
  119. #endif // #ifndef BOOST_MP11_DETAIL_MPL_COMMON_HPP_INCLUDED