list_to_cons.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*=============================================================================
  2. Copyright (c) 2014-2015 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. #ifndef FUSION_LIST_MAIN_10262014_0447
  7. #define FUSION_LIST_MAIN_10262014_0447
  8. #include <boost/config.hpp>
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/container/list/list_fwd.hpp>
  11. ///////////////////////////////////////////////////////////////////////////////
  12. // Without variadics, we will use the PP version
  13. ///////////////////////////////////////////////////////////////////////////////
  14. #if !defined(BOOST_FUSION_HAS_VARIADIC_LIST)
  15. # include <boost/fusion/container/list/detail/cpp03/list_to_cons.hpp>
  16. #else
  17. ///////////////////////////////////////////////////////////////////////////////
  18. // C++11 interface
  19. ///////////////////////////////////////////////////////////////////////////////
  20. #include <boost/fusion/container/list/cons.hpp>
  21. #include <boost/fusion/support/detail/access.hpp>
  22. namespace boost { namespace fusion { namespace detail
  23. {
  24. template <typename ...T>
  25. struct list_to_cons;
  26. template <>
  27. struct list_to_cons<>
  28. {
  29. typedef nil_ type;
  30. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  31. static type call() { return type(); }
  32. };
  33. template <typename Head, typename ...Tail>
  34. struct list_to_cons<Head, Tail...>
  35. {
  36. typedef Head head_type;
  37. typedef list_to_cons<Tail...> tail_list_to_cons;
  38. typedef typename tail_list_to_cons::type tail_type;
  39. typedef cons<head_type, tail_type> type;
  40. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  41. static type
  42. call(typename detail::call_param<Head>::type _h,
  43. typename detail::call_param<Tail>::type ..._t)
  44. {
  45. return type(_h, tail_list_to_cons::call(_t...));
  46. }
  47. };
  48. }}}
  49. #endif
  50. #endif