Index: convert.hpp =================================================================== --- convert.hpp (revision 83330) +++ convert.hpp (working copy) @@ -9,6 +9,33 @@ #include +namespace boost { namespace fusion { namespace detail +{ + template + struct pair_from + { + typedef typename result_of::value_of::type type; + + static inline type call(It const& it) + { + return *it; + } + }; + + template + struct pair_from + { + typedef typename result_of::key_of::type key_type; + typedef typename result_of::value_of_data::type data_type; + typedef typename fusion::pair type; + + static inline type call(It const& it) + { + return type(deref_data(it)); + } + }; +}}} + /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// @@ -30,6 +57,9 @@ detail::build_map< typename result_of::begin::type , typename result_of::end::type + , is_base_of< + associative_tag + , typename traits::category_of::type>::value > { }; Index: detail/build_map.hpp =================================================================== --- detail/build_map.hpp (revision 83330) +++ detail/build_map.hpp (working copy) @@ -18,12 +18,13 @@ namespace boost { namespace fusion { namespace detail { - template ::value> + template ::value + > struct build_map; - template - struct build_map + template + struct build_map { typedef map<> type; static type @@ -48,15 +49,15 @@ } }; - template - struct build_map + template + struct build_map { typedef - build_map::type, Last> + build_map::type, Last, is_assoc> next_build_map; typedef push_front_map< - typename result_of::value_of::type + typename pair_from::type , typename next_build_map::type> push_front; @@ -65,9 +66,9 @@ static type call(First const& f, Last const& l) { - typename result_of::value_of::type v = *f; return push_front::call( - v, next_build_map::call(fusion::next(f), l)); + pair_from::call(f) + , next_build_map::call(fusion::next(f), l)); } }; }}} Index: detail/cpp03/as_map.hpp =================================================================== --- detail/cpp03/as_map.hpp (revision 83330) +++ detail/cpp03/as_map.hpp (working copy) @@ -22,11 +22,11 @@ namespace boost { namespace fusion { namespace detail { - template + template struct as_map; - template <> - struct as_map<0> + template + struct as_map<0, is_assoc> { template struct apply @@ -73,17 +73,21 @@ typename gen::BOOST_PP_CAT(I, BOOST_PP_INC(n)) \ BOOST_PP_CAT(i, BOOST_PP_INC(n)) = fusion::next(BOOST_PP_CAT(i, n)); -#define BOOST_FUSION_VALUE_OF_ITERATOR(z, n, data) \ - typedef typename fusion::result_of::value_of::type \ - BOOST_PP_CAT(T, n); +#define BOOST_FUSION_PAIR_FROM_ITERATOR(z, n, data) \ + typedef pair_from BOOST_PP_CAT(D, n); \ + typedef typename BOOST_PP_CAT(D, n)::type BOOST_PP_CAT(T, n); +#define BOOST_FUSION_DREF_CALL_ITERATOR(z, n, data) \ + gen::BOOST_PP_CAT(D, n)::call(BOOST_PP_CAT(i, n)) + #define BOOST_PP_FILENAME_1 #define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_MAP_SIZE) #include BOOST_PP_ITERATE() #undef BOOST_FUSION_NEXT_ITERATOR #undef BOOST_FUSION_NEXT_CALL_ITERATOR -#undef BOOST_FUSION_VALUE_OF_ITERATOR +#undef BOOST_FUSION_PAIR_FROM_ITERATOR +#undef BOOST_FUSION_DREF_CALL_ITERATOR }}} @@ -103,14 +107,14 @@ #define N BOOST_PP_ITERATION() - template <> - struct as_map + template + struct as_map { template struct apply { - BOOST_PP_REPEAT(N, BOOST_FUSION_NEXT_ITERATOR, _) - BOOST_PP_REPEAT(N, BOOST_FUSION_VALUE_OF_ITERATOR, _) + BOOST_PP_REPEAT(BOOST_PP_DEC(N), BOOST_FUSION_NEXT_ITERATOR, _) + BOOST_PP_REPEAT(N, BOOST_FUSION_PAIR_FROM_ITERATOR, _) typedef map type; }; @@ -121,7 +125,7 @@ typedef apply gen; typedef typename gen::type result; BOOST_PP_REPEAT(BOOST_PP_DEC(N), BOOST_FUSION_NEXT_CALL_ITERATOR, _) - return result(BOOST_PP_ENUM_PARAMS(N, *i)); + return result(BOOST_PP_ENUM(N, BOOST_FUSION_DREF_CALL_ITERATOR, _)); } }; Index: detail/cpp03/convert.hpp =================================================================== --- detail/cpp03/convert.hpp (revision 83330) +++ detail/cpp03/convert.hpp (working copy) @@ -20,7 +20,14 @@ template struct as_map { - typedef typename detail::as_map::value> gen; + typedef typename + detail::as_map< + result_of::size::value + , is_base_of< + associative_tag + , typename traits::category_of::type>::value + > + gen; typedef typename gen:: template apply::type>::type type; Index: detail/cpp03/convert_impl.hpp =================================================================== --- detail/cpp03/convert_impl.hpp (revision 83330) +++ detail/cpp03/convert_impl.hpp (working copy) @@ -28,7 +28,14 @@ template struct apply { - typedef typename detail::as_map::value> gen; + typedef typename + detail::as_map< + result_of::size::value + , is_base_of< + associative_tag + , typename traits::category_of::type>::value + > + gen; typedef typename gen:: template apply::type>::type type;