From 9672fe538587efcb0f5485800d40de34d1fc12b4 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Mon, 4 Feb 2013 11:52:58 +0000 Subject: [PATCH] map move supported + value_at_impl added [SVN r82726] --- .../container/map/detail/value_at_impl.hpp | 37 +++++++++++++++++++ include/boost/fusion/container/map/map.hpp | 30 ++++++++++++++- include/boost/fusion/support/pair.hpp | 25 +++++++++++++ 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 include/boost/fusion/container/map/detail/value_at_impl.hpp diff --git a/include/boost/fusion/container/map/detail/value_at_impl.hpp b/include/boost/fusion/container/map/detail/value_at_impl.hpp new file mode 100644 index 00000000..75f2ddae --- /dev/null +++ b/include/boost/fusion/container/map/detail/value_at_impl.hpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2001-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_DETAIL_VALUE_AT_IMPL_02042013_0821) +#define BOOST_FUSION_MAP_DETAIL_VALUE_AT_IMPL_02042013_0821 + +#include + +namespace boost { namespace fusion +{ + struct map_tag; + + namespace extension + { + template + struct value_at_impl; + + template <> + struct value_at_impl + { + template + struct apply + { + typedef mpl::int_ index; + typedef + decltype(std::declval().get_val(index())) + type; + }; + }; + } +}} + +#endif + diff --git a/include/boost/fusion/container/map/map.hpp b/include/boost/fusion/container/map/map.hpp index 1ac36717..327c2e53 100644 --- a/include/boost/fusion/container/map/map.hpp +++ b/include/boost/fusion/container/map/map.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,14 @@ namespace boost { namespace fusion map() {} + map(map const& seq) + : base_type(seq.base()) + {} + + map(map&& seq) + : base_type(std::forward(seq)) + {} + template map(Sequence const& seq , typename enable_if>::type* /*dummy*/ = 0) @@ -64,22 +73,39 @@ 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...) {} template - map(First& first, T_&... rest) - : base_type(first, rest...) + map(First&& first, T_&&... rest) + : base_type(std::forward(first), std::forward(rest)...) {} + //~ template + //~ map(First& first, T_&... rest) + //~ : base_type(first, rest...) + //~ {} + map& operator=(map const& rhs) { base_type::operator=(rhs.base()); return *this; } + map& operator=(map&& rhs) + { + base_type::operator=(std::forward(rhs.base())); + return *this; + } + template typename enable_if, map&>::type operator=(Sequence const& seq) diff --git a/include/boost/fusion/support/pair.hpp b/include/boost/fusion/support/pair.hpp index a5ba6ca4..0c04f379 100644 --- a/include/boost/fusion/support/pair.hpp +++ b/include/boost/fusion/support/pair.hpp @@ -28,9 +28,26 @@ namespace boost { namespace fusion pair() : second() {} + pair(pair const& rhs) + : second(rhs.second) {} + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + pair(pair&& rhs) + : second(std::forward(rhs.second)) {} +#endif + pair(typename detail::call_param::type val) : second(val) {} +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + + template + pair(Second2&& val + , typename boost::enable_if >::type* /*dummy*/ = 0 + ) : second(std::forward(val)) {} + +#endif + template pair(pair const& rhs) : second(rhs.second) {} @@ -48,6 +65,14 @@ namespace boost { namespace fusion return *this; } +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + pair& operator=(pair&& rhs) + { + second = std::forward(rhs.second); + return *this; + } +#endif + typedef First first_type; typedef Second second_type; Second second;