More map tests and more API features implemented + tweaks to affected components

[SVN r82713]
This commit is contained in:
Joel de Guzman
2013-02-04 06:21:45 +00:00
parent aba201eb4e
commit 228401d898
6 changed files with 68 additions and 6 deletions

View File

@ -74,13 +74,18 @@ namespace boost { namespace fusion
#include <boost/fusion/container/map/detail/cpp03/map_forward_ctor.hpp> #include <boost/fusion/container/map/detail/cpp03/map_forward_ctor.hpp>
template <typename T> template <typename T>
map& map& operator=(T const& rhs)
operator=(T const& rhs)
{ {
data = rhs; data = rhs;
return *this; return *this;
} }
map& operator=(map const& rhs)
{
data = rhs.data;
return *this;
}
storage_type& get_data() { return data; } storage_type& get_data() { return data; }
storage_type const& get_data() const { return data; } storage_type const& get_data() const { return data; }

View File

@ -38,6 +38,10 @@ namespace boost { namespace fusion { namespace detail
map_impl(Iterator const& iter, map_impl_from_iterator) map_impl(Iterator const& iter, map_impl_from_iterator)
{} {}
template <typename Iterator>
void assign(Iterator const& iter, map_impl_from_iterator)
{}
void get(); void get();
void get_val(); void get_val();
void get_key(); void get_key();
@ -158,6 +162,13 @@ namespace boost { namespace fusion { namespace detail
return *this; return *this;
} }
template <typename Iterator>
void assign(Iterator const& iter, map_impl_from_iterator fi)
{
rest_type::assign(fusion::next(iter), fi);
element = *iter;
}
Pair element; Pair element;
}; };
}}} }}}

View File

@ -8,6 +8,7 @@
#define FUSION_MAP_MAIN_07212005_1106 #define FUSION_MAP_MAIN_07212005_1106
#include <boost/fusion/container/map/map_fwd.hpp> #include <boost/fusion/container/map/map_fwd.hpp>
#include <boost/fusion/support/pair.hpp>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Without variadics, we will use the PP version // Without variadics, we will use the PP version
@ -29,9 +30,12 @@
#include <boost/fusion/sequence/intrinsic/end.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp> #include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/at_c.hpp> #include <boost/fusion/sequence/intrinsic/at_c.hpp>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/support/sequence_base.hpp> #include <boost/fusion/support/sequence_base.hpp>
#include <boost/fusion/support/category_of.hpp> #include <boost/fusion/support/category_of.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
struct map_tag; struct map_tag;
@ -46,11 +50,40 @@ namespace boost { namespace fusion
typedef mpl::int_<base_type::size> size; typedef mpl::int_<base_type::size> size;
typedef mpl::false_ is_view; typedef mpl::false_ is_view;
map() {}; map() {}
map(typename detail::call_param<T>::type... element) template <typename Sequence>
: base_type(element...) map(Sequence const& seq
, typename enable_if<traits::is_sequence<Sequence>>::type* /*dummy*/ = 0)
: base_type(begin(seq), detail::map_impl_from_iterator())
{} {}
template <typename First, typename ...T_>
map(First const& first, T_ const&... rest)
: base_type(first, rest...)
{}
template <typename First, typename ...T_>
map(First& first, T_&... rest)
: base_type(first, rest...)
{}
map& operator=(map const& rhs)
{
base_type::operator=(rhs.base());
return *this;
}
template <typename Sequence>
typename enable_if<traits::is_sequence<Sequence>, 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; }
}; };
}} }}

View File

@ -204,7 +204,7 @@
BOOST_PP_CAT(vector, N)& BOOST_PP_CAT(vector, N)&
operator=(BOOST_PP_CAT(vector, N) const& vec) operator=(BOOST_PP_CAT(vector, N) const& vec)
{ {
base_type::operator=(*this); base_type::operator=(vec);
return *this; return *this;
} }

View File

@ -140,6 +140,13 @@ namespace boost { namespace fusion
return *this; return *this;
} }
vector&
operator=(vector const& rhs)
{
vec = rhs.vec;
return *this;
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
vector& vector&
operator=(vector&& rhs) operator=(vector&& rhs)

View File

@ -42,6 +42,12 @@ namespace boost { namespace fusion
return *this; return *this;
} }
pair& operator=(pair const& rhs)
{
second = rhs.second;
return *this;
}
typedef First first_type; typedef First first_type;
typedef Second second_type; typedef Second second_type;
Second second; Second second;