build_cons.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*=============================================================================
  2. Copyright (c) 2012-2014 Kohei Takahashi
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !defined(BOOST_FUSION_BUILD_CONS_10172012_0130)
  7. #define BOOST_FUSION_BUILD_CONS_10172012_0130
  8. #include <boost/tuple/tuple.hpp>
  9. #include <boost/fusion/iterator/equal_to.hpp>
  10. #include <boost/fusion/iterator/next.hpp>
  11. #include <boost/fusion/iterator/value_of.hpp>
  12. #include <boost/fusion/iterator/deref.hpp>
  13. namespace boost { namespace fusion { namespace detail
  14. {
  15. template <
  16. typename First
  17. , typename Last
  18. , bool is_empty = result_of::equal_to<First, Last>::value>
  19. struct build_tuple_cons;
  20. template <typename First, typename Last>
  21. struct build_tuple_cons<First, Last, true>
  22. {
  23. typedef boost::tuples::null_type type;
  24. BOOST_FUSION_GPU_ENABLED
  25. static type
  26. call(First const&, Last const&)
  27. {
  28. return type();
  29. }
  30. };
  31. template <typename First, typename Last>
  32. struct build_tuple_cons<First, Last, false>
  33. {
  34. typedef
  35. build_tuple_cons<typename result_of::next<First>::type, Last>
  36. next_build_tuple_cons;
  37. typedef boost::tuples::cons<
  38. typename result_of::value_of<First>::type
  39. , typename next_build_tuple_cons::type>
  40. type;
  41. BOOST_FUSION_GPU_ENABLED
  42. static type
  43. call(First const& f, Last const& l)
  44. {
  45. typename result_of::value_of<First>::type v = *f;
  46. return type(v, next_build_tuple_cons::call(fusion::next(f), l));
  47. }
  48. };
  49. }}}
  50. #endif