Chris@16: /*============================================================================= Chris@16: Copyright (c) 2001-2011 Joel de Guzman Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: ==============================================================================*/ Chris@16: #if !defined(FUSION_CONVERT_MAIN_09232005_1340) Chris@16: #define FUSION_CONVERT_MAIN_09232005_1340 Chris@16: Chris@101: #include Chris@16: #include Chris@16: Chris@101: namespace boost { namespace fusion { namespace detail Chris@101: { Chris@101: template Chris@101: struct pair_from Chris@101: { Chris@101: typedef typename result_of::value_of::type type; Chris@101: Chris@101: BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED Chris@101: static inline type call(It const& it) Chris@101: { Chris@101: return *it; Chris@101: } Chris@101: }; Chris@101: Chris@101: template Chris@101: struct pair_from Chris@101: { Chris@101: typedef typename result_of::key_of::type key_type; Chris@101: typedef typename result_of::value_of_data::type data_type; Chris@101: typedef typename fusion::pair type; Chris@101: Chris@101: BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED Chris@101: static inline type call(It const& it) Chris@101: { Chris@101: return type(deref_data(it)); Chris@101: } Chris@101: }; Chris@101: }}} Chris@101: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: // Without variadics, we will use the PP version Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: #if !defined(BOOST_FUSION_HAS_VARIADIC_MAP) Chris@16: # include Chris@16: Chris@16: #else Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: // C++11 variadic implementation Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: #include Chris@16: Chris@16: namespace boost { namespace fusion Chris@16: { Chris@16: namespace result_of Chris@16: { Chris@16: template Chris@16: struct as_map : Chris@16: detail::build_map< Chris@16: typename result_of::begin::type Chris@16: , typename result_of::end::type Chris@101: , is_base_of< Chris@101: associative_tag Chris@101: , typename traits::category_of::type>::value Chris@16: > Chris@16: { Chris@16: }; Chris@16: } Chris@16: Chris@16: template Chris@101: BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED Chris@16: inline typename result_of::as_map::type Chris@16: as_map(Sequence& seq) Chris@16: { Chris@16: typedef result_of::as_map gen; Chris@16: return gen::call(fusion::begin(seq), fusion::end(seq)); Chris@16: } Chris@16: Chris@16: template Chris@101: BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED Chris@16: inline typename result_of::as_map::type Chris@16: as_map(Sequence const& seq) Chris@16: { Chris@16: typedef result_of::as_map gen; Chris@16: return gen::call(fusion::begin(seq), fusion::end(seq)); Chris@16: } Chris@16: Chris@16: namespace extension Chris@16: { Chris@16: template Chris@16: struct convert_impl; Chris@16: Chris@16: template <> Chris@16: struct convert_impl Chris@16: { Chris@16: template Chris@16: struct apply Chris@16: { Chris@16: typedef typename Chris@16: result_of::as_map::type Chris@16: type; Chris@16: Chris@101: BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED Chris@16: static type call(Sequence& seq) Chris@16: { Chris@16: typedef result_of::as_map gen; Chris@16: return gen::call(fusion::begin(seq), fusion::end(seq)); Chris@16: } Chris@16: }; Chris@16: }; Chris@16: } Chris@16: }} Chris@16: Chris@16: #endif Chris@16: #endif Chris@16: