make_map.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*=============================================================================
  2. Copyright (c) 2001-2013 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_MAKE_MAP_07222005_1247)
  7. #define FUSION_MAKE_MAP_07222005_1247
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/container/map/map.hpp>
  10. #if !defined(BOOST_FUSION_HAS_VARIADIC_MAP)
  11. # include <boost/fusion/container/generation/detail/pp_make_map.hpp>
  12. #else
  13. ///////////////////////////////////////////////////////////////////////////////
  14. // C++11 variadic interface
  15. ///////////////////////////////////////////////////////////////////////////////
  16. #include <boost/fusion/support/detail/as_fusion_element.hpp>
  17. #include <boost/fusion/support/pair.hpp>
  18. namespace boost { namespace fusion
  19. {
  20. namespace result_of
  21. {
  22. template <typename ...Key>
  23. struct make_map
  24. {
  25. template <typename ...T>
  26. struct apply
  27. {
  28. typedef map<
  29. fusion::pair<
  30. Key
  31. , typename detail::as_fusion_element<T>::type
  32. >...>
  33. type;
  34. };
  35. };
  36. }
  37. template <typename ...Key, typename ...T>
  38. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  39. inline map<
  40. fusion::pair<
  41. Key
  42. , typename detail::as_fusion_element<T>::type
  43. >...>
  44. make_map(T const&... arg)
  45. {
  46. typedef map<
  47. fusion::pair<
  48. Key
  49. , typename detail::as_fusion_element<T>::type
  50. >...>
  51. result_type;
  52. return result_type(arg...);
  53. }
  54. }}
  55. #endif
  56. #endif