build_cons.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  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(FUSION_BUILD_CONS_09232005_1222)
  7. #define FUSION_BUILD_CONS_09232005_1222
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/container/list/cons.hpp>
  10. #include <boost/fusion/iterator/equal_to.hpp>
  11. #include <boost/fusion/iterator/next.hpp>
  12. #include <boost/fusion/iterator/value_of.hpp>
  13. #include <boost/fusion/iterator/deref.hpp>
  14. namespace boost { namespace fusion { namespace detail
  15. {
  16. template <
  17. typename First
  18. , typename Last
  19. , bool is_empty = result_of::equal_to<First, Last>::value>
  20. struct build_cons;
  21. template <typename First, typename Last>
  22. struct build_cons<First, Last, true>
  23. {
  24. typedef nil_ type;
  25. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  26. static nil_
  27. call(First const&, Last const&)
  28. {
  29. return nil_();
  30. }
  31. };
  32. template <typename First, typename Last>
  33. struct build_cons<First, Last, false>
  34. {
  35. typedef
  36. build_cons<typename result_of::next<First>::type, Last>
  37. next_build_cons;
  38. typedef cons<
  39. typename result_of::value_of<First>::type
  40. , typename next_build_cons::type>
  41. type;
  42. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  43. static type
  44. call(First const& f, Last const& l)
  45. {
  46. typename result_of::value_of<First>::type v = *f;
  47. return type(v, next_build_cons::call(fusion::next(f), l));
  48. }
  49. };
  50. }}}
  51. #endif