map move supported + value_at_impl added

[SVN r82726]
This commit is contained in:
Joel de Guzman
2013-02-04 11:52:58 +00:00
parent 085c3c25ca
commit 9672fe5385
3 changed files with 90 additions and 2 deletions

View File

@ -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 <boost/mpl/at.hpp>
namespace boost { namespace fusion
{
struct map_tag;
namespace extension
{
template <typename Tag>
struct value_at_impl;
template <>
struct value_at_impl<map_tag>
{
template <typename Sequence, typename N>
struct apply
{
typedef mpl::int_<N::value> index;
typedef
decltype(std::declval<Sequence>().get_val(index()))
type;
};
};
}
}}
#endif

View File

@ -25,6 +25,7 @@
#include <boost/fusion/container/map/detail/end_impl.hpp> #include <boost/fusion/container/map/detail/end_impl.hpp>
#include <boost/fusion/container/map/detail/at_impl.hpp> #include <boost/fusion/container/map/detail/at_impl.hpp>
#include <boost/fusion/container/map/detail/at_key_impl.hpp> #include <boost/fusion/container/map/detail/at_key_impl.hpp>
#include <boost/fusion/container/map/detail/value_at_impl.hpp>
#include <boost/fusion/container/map/detail/value_at_key_impl.hpp> #include <boost/fusion/container/map/detail/value_at_key_impl.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp>
@ -52,6 +53,14 @@ namespace boost { namespace fusion
map() {} map() {}
map(map const& seq)
: base_type(seq.base())
{}
map(map&& seq)
: base_type(std::forward<map>(seq))
{}
template <typename Sequence> template <typename Sequence>
map(Sequence const& seq map(Sequence const& seq
, typename enable_if<traits::is_sequence<Sequence>>::type* /*dummy*/ = 0) , typename enable_if<traits::is_sequence<Sequence>>::type* /*dummy*/ = 0)
@ -64,22 +73,39 @@ namespace boost { namespace fusion
: base_type(begin(seq), detail::map_impl_from_iterator()) : base_type(begin(seq), detail::map_impl_from_iterator())
{} {}
template <typename Sequence>
map(Sequence&& 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_> template <typename First, typename ...T_>
map(First const& first, T_ const&... rest) map(First const& first, T_ const&... rest)
: base_type(first, rest...) : base_type(first, rest...)
{} {}
template <typename First, typename ...T_> template <typename First, typename ...T_>
map(First& first, T_&... rest) map(First&& first, T_&&... rest)
: base_type(first, rest...) : base_type(std::forward<First>(first), std::forward<T_>(rest)...)
{} {}
//~ template <typename First, typename ...T_>
//~ map(First& first, T_&... rest)
//~ : base_type(first, rest...)
//~ {}
map& operator=(map const& rhs) map& operator=(map const& rhs)
{ {
base_type::operator=(rhs.base()); base_type::operator=(rhs.base());
return *this; return *this;
} }
map& operator=(map&& rhs)
{
base_type::operator=(std::forward<base_type>(rhs.base()));
return *this;
}
template <typename Sequence> template <typename Sequence>
typename enable_if<traits::is_sequence<Sequence>, map&>::type typename enable_if<traits::is_sequence<Sequence>, map&>::type
operator=(Sequence const& seq) operator=(Sequence const& seq)

View File

@ -28,9 +28,26 @@ namespace boost { namespace fusion
pair() pair()
: second() {} : second() {}
pair(pair const& rhs)
: second(rhs.second) {}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
pair(pair&& rhs)
: second(std::forward<Second>(rhs.second)) {}
#endif
pair(typename detail::call_param<Second>::type val) pair(typename detail::call_param<Second>::type val)
: second(val) {} : second(val) {}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template <typename Second2>
pair(Second2&& val
, typename boost::enable_if<is_convertible<Second2, Second> >::type* /*dummy*/ = 0
) : second(std::forward<Second2>(val)) {}
#endif
template <typename Second2> template <typename Second2>
pair(pair<First, Second2> const& rhs) pair(pair<First, Second2> const& rhs)
: second(rhs.second) {} : second(rhs.second) {}
@ -48,6 +65,14 @@ namespace boost { namespace fusion
return *this; return *this;
} }
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
pair& operator=(pair&& rhs)
{
second = std::forward<Second>(rhs.second);
return *this;
}
#endif
typedef First first_type; typedef First first_type;
typedef Second second_type; typedef Second second_type;
Second second; Second second;