From 228401d8986041da20ec4b27bea4b0a940a3e32b Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Mon, 4 Feb 2013 06:21:45 +0000 Subject: [PATCH] More map tests and more API features implemented + tweaks to affected components [SVN r82713] --- .../fusion/container/map/detail/cpp03/map.hpp | 9 ++++- .../fusion/container/map/detail/map_impl.hpp | 11 ++++++ include/boost/fusion/container/map/map.hpp | 39 +++++++++++++++++-- .../container/vector/detail/vector_n.hpp | 2 +- .../boost/fusion/container/vector/vector.hpp | 7 ++++ include/boost/fusion/support/pair.hpp | 6 +++ 6 files changed, 68 insertions(+), 6 deletions(-) diff --git a/include/boost/fusion/container/map/detail/cpp03/map.hpp b/include/boost/fusion/container/map/detail/cpp03/map.hpp index e0abd49c..74e4f599 100644 --- a/include/boost/fusion/container/map/detail/cpp03/map.hpp +++ b/include/boost/fusion/container/map/detail/cpp03/map.hpp @@ -74,13 +74,18 @@ namespace boost { namespace fusion #include template - map& - operator=(T const& rhs) + map& operator=(T const& rhs) { data = rhs; return *this; } + map& operator=(map const& rhs) + { + data = rhs.data; + return *this; + } + storage_type& get_data() { return data; } storage_type const& get_data() const { return data; } diff --git a/include/boost/fusion/container/map/detail/map_impl.hpp b/include/boost/fusion/container/map/detail/map_impl.hpp index 7f313f4c..cea25496 100644 --- a/include/boost/fusion/container/map/detail/map_impl.hpp +++ b/include/boost/fusion/container/map/detail/map_impl.hpp @@ -38,6 +38,10 @@ namespace boost { namespace fusion { namespace detail map_impl(Iterator const& iter, map_impl_from_iterator) {} + template + void assign(Iterator const& iter, map_impl_from_iterator) + {} + void get(); void get_val(); void get_key(); @@ -158,6 +162,13 @@ namespace boost { namespace fusion { namespace detail return *this; } + template + void assign(Iterator const& iter, map_impl_from_iterator fi) + { + rest_type::assign(fusion::next(iter), fi); + element = *iter; + } + Pair element; }; }}} diff --git a/include/boost/fusion/container/map/map.hpp b/include/boost/fusion/container/map/map.hpp index 106b6658..c74259ff 100644 --- a/include/boost/fusion/container/map/map.hpp +++ b/include/boost/fusion/container/map/map.hpp @@ -8,6 +8,7 @@ #define FUSION_MAP_MAIN_07212005_1106 #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version @@ -29,9 +30,12 @@ #include #include #include +#include #include #include +#include + namespace boost { namespace fusion { struct map_tag; @@ -46,11 +50,40 @@ namespace boost { namespace fusion typedef mpl::int_ size; typedef mpl::false_ is_view; - map() {}; + map() {} - map(typename detail::call_param::type... element) - : base_type(element...) + template + map(Sequence const& 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& operator=(map const& rhs) + { + base_type::operator=(rhs.base()); + return *this; + } + + template + typename enable_if, map&>::type + operator=(Sequence const& seq) + { + base().assign(begin(seq), detail::map_impl_from_iterator()); + return *this; + } + + base_type& base() { return *this; } + base_type const& base() const { return *this; } }; }} diff --git a/include/boost/fusion/container/vector/detail/vector_n.hpp b/include/boost/fusion/container/vector/detail/vector_n.hpp index 011a32df..2da75b77 100644 --- a/include/boost/fusion/container/vector/detail/vector_n.hpp +++ b/include/boost/fusion/container/vector/detail/vector_n.hpp @@ -204,7 +204,7 @@ BOOST_PP_CAT(vector, N)& operator=(BOOST_PP_CAT(vector, N) const& vec) { - base_type::operator=(*this); + base_type::operator=(vec); return *this; } diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index 9d5d8725..94a9c71a 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -140,6 +140,13 @@ namespace boost { namespace fusion return *this; } + vector& + operator=(vector const& rhs) + { + vec = rhs.vec; + return *this; + } + #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) vector& operator=(vector&& rhs) diff --git a/include/boost/fusion/support/pair.hpp b/include/boost/fusion/support/pair.hpp index 642afdfa..a5ba6ca4 100644 --- a/include/boost/fusion/support/pair.hpp +++ b/include/boost/fusion/support/pair.hpp @@ -42,6 +42,12 @@ namespace boost { namespace fusion return *this; } + pair& operator=(pair const& rhs) + { + second = rhs.second; + return *this; + } + typedef First first_type; typedef Second second_type; Second second;