1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #if !defined(FUSION_CONVERT_MAIN_09232005_1340)
8 #define FUSION_CONVERT_MAIN_09232005_1340
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/container/map/map.hpp>
13 namespace boost { namespace fusion { namespace detail
15 template <typename It, bool is_assoc>
18 typedef typename result_of::value_of<It>::type type;
20 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
21 static inline type call(It const& it)
27 template <typename It>
28 struct pair_from<It, true>
30 typedef typename result_of::key_of<It>::type key_type;
31 typedef typename result_of::value_of_data<It>::type data_type;
32 typedef typename fusion::pair<key_type, data_type> type;
34 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
35 static inline type call(It const& it)
37 return type(deref_data(it));
42 ///////////////////////////////////////////////////////////////////////////////
43 // Without variadics, we will use the PP version
44 ///////////////////////////////////////////////////////////////////////////////
45 #if !defined(BOOST_FUSION_HAS_VARIADIC_MAP)
46 # include <boost/fusion/container/map/detail/cpp03/convert.hpp>
49 ///////////////////////////////////////////////////////////////////////////////
50 // C++11 variadic implementation
51 ///////////////////////////////////////////////////////////////////////////////
52 #include <boost/fusion/container/map/detail/build_map.hpp>
54 namespace boost { namespace fusion
58 template <typename Sequence>
61 typename result_of::begin<Sequence>::type
62 , typename result_of::end<Sequence>::type
65 , typename traits::category_of<Sequence>::type>::value
71 template <typename Sequence>
72 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
73 inline typename result_of::as_map<Sequence>::type
76 typedef result_of::as_map<Sequence> gen;
77 return gen::call(fusion::begin(seq), fusion::end(seq));
80 template <typename Sequence>
81 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
82 inline typename result_of::as_map<Sequence const>::type
83 as_map(Sequence const& seq)
85 typedef result_of::as_map<Sequence const> gen;
86 return gen::call(fusion::begin(seq), fusion::end(seq));
95 struct convert_impl<map_tag>
97 template <typename Sequence>
101 result_of::as_map<Sequence>::type
104 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
105 static type call(Sequence& seq)
107 typedef result_of::as_map<Sequence> gen;
108 return gen::call(fusion::begin(seq), fusion::end(seq));