diff --git a/include/boost/fusion/container/deque/convert.hpp b/include/boost/fusion/container/deque/convert.hpp index 4f9eb7ce..0dc1dc0a 100644 --- a/include/boost/fusion/container/deque/convert.hpp +++ b/include/boost/fusion/container/deque/convert.hpp @@ -41,7 +41,7 @@ namespace boost { namespace fusion inline typename result_of::as_deque::type as_deque(Sequence& seq) { - typedef typename result_of::as_deque::gen gen; + typedef result_of::as_deque gen; return gen::call(fusion::begin(seq), fusion::end(seq)); } @@ -49,7 +49,7 @@ namespace boost { namespace fusion inline typename result_of::as_deque::type as_deque(Sequence const& seq) { - typedef typename result_of::as_deque::gen gen; + typedef result_of::as_deque gen; return gen::call(fusion::begin(seq), fusion::end(seq)); } }} diff --git a/include/boost/fusion/container/map/convert.hpp b/include/boost/fusion/container/map/convert.hpp index 5c93bbc0..b6d7285b 100644 --- a/include/boost/fusion/container/map/convert.hpp +++ b/include/boost/fusion/container/map/convert.hpp @@ -7,6 +7,51 @@ #if !defined(FUSION_CONVERT_MAIN_09232005_1340) #define FUSION_CONVERT_MAIN_09232005_1340 -#include +#include + +/////////////////////////////////////////////////////////////////////////////// +// Without variadics, we will use the PP version +/////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_MAP) +# include + +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic implementation +/////////////////////////////////////////////////////////////////////////////// +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct as_map : + detail::build_map< + typename result_of::begin::type + , typename result_of::end::type + > + { + }; + } + + template + inline typename result_of::as_map::type + as_map(Sequence& seq) + { + typedef result_of::as_map gen; + return gen::call(fusion::begin(seq), fusion::end(seq)); + } + + template + inline typename result_of::as_map::type + as_map(Sequence const& seq) + { + typedef result_of::as_map gen; + return gen::call(fusion::begin(seq), fusion::end(seq)); + } +}} #endif +#endif + diff --git a/include/boost/fusion/container/map/detail/at_impl.hpp b/include/boost/fusion/container/map/detail/at_impl.hpp index 176b1103..3a16100b 100644 --- a/include/boost/fusion/container/map/detail/at_impl.hpp +++ b/include/boost/fusion/container/map/detail/at_impl.hpp @@ -24,28 +24,30 @@ namespace boost { namespace fusion template struct apply { + typedef mpl::int_ index; typedef - decltype(std::declval().get(N())) + decltype(std::declval().get(index())) type; static type call(Sequence& m) { - return m.get(N()); + return m.get(index()); } }; template struct apply { + typedef mpl::int_ index; typedef - decltype(std::declval().get(N())) + decltype(std::declval().get(index())) type; static type call(Sequence const& m) { - return m.get(N()); + return m.get(index()); } }; }; diff --git a/include/boost/fusion/container/map/detail/build_map.hpp b/include/boost/fusion/container/map/detail/build_map.hpp new file mode 100644 index 00000000..8170b276 --- /dev/null +++ b/include/boost/fusion/container/map/detail/build_map.hpp @@ -0,0 +1,75 @@ +/*============================================================================= + Copyright (c) 2005-2013 Joel de Guzman + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_BUILD_MAP_02042013_1448) +#define BOOST_FUSION_BUILD_MAP_02042013_1448 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ + template ::value> + struct build_map; + + template + struct build_map + { + typedef map<> type; + static type + call(First const&, Last const&) + { + return type(); + } + }; + + template + struct push_front_map; + + template + struct push_front_map> + { + typedef map type; + + static type + call(T const& first, map const& rest) + { + return type(push_front(rest, first)); + } + }; + + template + struct build_map + { + typedef + build_map::type, Last> + next_build_map; + + typedef push_front_map< + typename result_of::value_of::type + , typename next_build_map::type> + push_front; + + typedef typename push_front::type type; + + 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)); + } + }; +}}} + +#endif diff --git a/include/boost/fusion/container/map/detail/map_index.hpp b/include/boost/fusion/container/map/detail/map_index.hpp new file mode 100644 index 00000000..9326cded --- /dev/null +++ b/include/boost/fusion/container/map/detail/map_index.hpp @@ -0,0 +1,19 @@ +/*============================================================================= + Copyright (c) 2005-2013 Joel de Guzman + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_MAP_INDEX_02032013_2233) +#define BOOST_FUSION_MAP_INDEX_02032013_2233 + +namespace boost { namespace fusion { namespace detail +{ + template + struct map_index + { + static int const value = N; + }; +}}} + +#endif diff --git a/include/boost/fusion/container/map/map.hpp b/include/boost/fusion/container/map/map.hpp index c74259ff..1ac36717 100644 --- a/include/boost/fusion/container/map/map.hpp +++ b/include/boost/fusion/container/map/map.hpp @@ -58,6 +58,12 @@ namespace boost { namespace fusion : base_type(begin(seq), detail::map_impl_from_iterator()) {} + template + map(Sequence& seq + , typename enable_if>::type* /*dummy*/ = 0) + : base_type(begin(seq), detail::map_impl_from_iterator()) + {} + template map(First const& first, T_ const&... rest) : base_type(first, rest...) diff --git a/include/boost/fusion/container/map/map_iterator.hpp b/include/boost/fusion/container/map/map_iterator.hpp index 7761fdba..a4ad80f0 100644 --- a/include/boost/fusion/container/map/map_iterator.hpp +++ b/include/boost/fusion/container/map/map_iterator.hpp @@ -20,7 +20,7 @@ namespace boost { namespace fusion struct map_iterator : iterator_facade< map_iterator - , random_access_traversal_tag> + , typename Seq::category> { typedef Seq sequence; typedef mpl::int_ index; @@ -91,22 +91,6 @@ namespace boost { namespace fusion } }; - //~ template - //~ struct deref_data - //~ { - //~ typedef typename Iterator::sequence sequence; - //~ typedef typename Iterator::index index; - //~ typedef - //~ decltype(std::declval().get(index())) - //~ type; - - //~ static type - //~ call(Iterator const& it) - //~ { - //~ return it.seq_.get(typename Iterator::index()); - //~ } - //~ }; - template struct advance { @@ -132,7 +116,7 @@ namespace boost { namespace fusion {}; template - struct distance : mpl::minus + struct distance { typedef typename mpl::minus<