convert.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_1340)
  7. #define FUSION_CONVERT_09232005_1340
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/container/map/detail/cpp03/as_map.hpp>
  10. #include <boost/fusion/container/map/detail/cpp03/convert_impl.hpp>
  11. #include <boost/fusion/container/map/detail/cpp03/map.hpp>
  12. #include <boost/fusion/sequence/intrinsic/begin.hpp>
  13. #include <boost/fusion/sequence/intrinsic/size.hpp>
  14. namespace boost { namespace fusion
  15. {
  16. namespace result_of
  17. {
  18. template <typename Sequence>
  19. struct as_map
  20. {
  21. typedef typename
  22. detail::as_map<
  23. result_of::size<Sequence>::value
  24. , is_base_of<
  25. associative_tag
  26. , typename traits::category_of<Sequence>::type>::value
  27. >
  28. gen;
  29. typedef typename gen::
  30. template apply<typename result_of::begin<Sequence>::type>::type
  31. type;
  32. };
  33. }
  34. template <typename Sequence>
  35. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  36. inline typename result_of::as_map<Sequence>::type
  37. as_map(Sequence& seq)
  38. {
  39. typedef typename result_of::as_map<Sequence>::gen gen;
  40. return gen::call(fusion::begin(seq));
  41. }
  42. template <typename Sequence>
  43. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  44. inline typename result_of::as_map<Sequence const>::type
  45. as_map(Sequence const& seq)
  46. {
  47. typedef typename result_of::as_map<Sequence const>::gen gen;
  48. return gen::call(fusion::begin(seq));
  49. }
  50. }}
  51. #endif