deque_keyed_values.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*=============================================================================
  2. Copyright (c) 2005-2012 Joel de Guzman
  3. Copyright (c) 2005-2006 Dan Marsden
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #if !defined(BOOST_FUSION_DEQUE_DETAIL_CPP11_DEQUE_KEYED_VALUES_07042012_1901)
  8. #define BOOST_FUSION_DEQUE_DETAIL_CPP11_DEQUE_KEYED_VALUES_07042012_1901
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/support/detail/access.hpp>
  11. #include <boost/fusion/container/deque/detail/keyed_element.hpp>
  12. #include <boost/mpl/int.hpp>
  13. namespace boost { namespace fusion { namespace detail
  14. {
  15. template<typename Key, typename Value, typename Rest>
  16. struct keyed_element;
  17. template <typename N, typename ...Elements>
  18. struct deque_keyed_values_impl;
  19. template <typename N, typename Head, typename ...Tail>
  20. struct deque_keyed_values_impl<N, Head, Tail...>
  21. {
  22. typedef mpl::int_<(N::value + 1)> next_index;
  23. typedef typename deque_keyed_values_impl<next_index, Tail...>::type tail;
  24. typedef keyed_element<N, Head, tail> type;
  25. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  26. static type construct(
  27. typename detail::call_param<Head>::type head
  28. , typename detail::call_param<Tail>::type... tail)
  29. {
  30. return type(
  31. head
  32. , deque_keyed_values_impl<next_index, Tail...>::construct(tail...)
  33. );
  34. }
  35. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  36. template <typename Head_, typename ...Tail_>
  37. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  38. static type forward_(Head_&& head, Tail_&&... tail)
  39. {
  40. return type(
  41. BOOST_FUSION_FWD_ELEM(Head_, head)
  42. , deque_keyed_values_impl<next_index, Tail_...>::
  43. forward_(BOOST_FUSION_FWD_ELEM(Tail_, tail)...)
  44. );
  45. }
  46. #endif
  47. };
  48. struct nil_keyed_element;
  49. template <typename N>
  50. struct deque_keyed_values_impl<N>
  51. {
  52. typedef nil_keyed_element type;
  53. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  54. static type construct() { return type(); }
  55. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  56. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  57. static type forward_() { return type(); }
  58. #endif
  59. };
  60. template <typename ...Elements>
  61. struct deque_keyed_values
  62. : deque_keyed_values_impl<mpl::int_<0>, Elements...> {};
  63. }}}
  64. #endif