convert.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_CONVERT_09232005_1215)
  7. #define FUSION_CONVERT_09232005_1215
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/container/list/cons.hpp>
  10. #include <boost/fusion/container/list/detail/build_cons.hpp>
  11. #include <boost/fusion/container/list/detail/convert_impl.hpp>
  12. #include <boost/fusion/sequence/intrinsic/empty.hpp>
  13. #include <boost/fusion/sequence/intrinsic/begin.hpp>
  14. #include <boost/fusion/sequence/intrinsic/end.hpp>
  15. namespace boost { namespace fusion
  16. {
  17. namespace result_of
  18. {
  19. template <typename Sequence>
  20. struct as_list
  21. {
  22. typedef typename
  23. detail::build_cons<
  24. typename result_of::begin<Sequence>::type
  25. , typename result_of::end<Sequence>::type
  26. >
  27. build_cons;
  28. typedef typename build_cons::type type;
  29. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  30. static type
  31. call(Sequence& seq)
  32. {
  33. return build_cons::call(fusion::begin(seq), fusion::end(seq));
  34. }
  35. };
  36. }
  37. template <typename Sequence>
  38. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  39. inline typename result_of::as_list<Sequence>::type
  40. as_list(Sequence& seq)
  41. {
  42. return result_of::as_list<Sequence>::call(seq);
  43. }
  44. template <typename Sequence>
  45. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  46. inline typename result_of::as_list<Sequence const>::type
  47. as_list(Sequence const& seq)
  48. {
  49. return result_of::as_list<Sequence const>::call(seq);
  50. }
  51. }}
  52. #endif