2013-02-04 03:49:34 +00:00
|
|
|
/*=============================================================================
|
|
|
|
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_IMPL_02032013_2233)
|
|
|
|
#define BOOST_FUSION_MAP_IMPL_02032013_2233
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
#include <boost/fusion/support/config.hpp>
|
2013-02-04 03:49:34 +00:00
|
|
|
#include <boost/fusion/support/detail/access.hpp>
|
|
|
|
#include <boost/fusion/iterator/deref.hpp>
|
|
|
|
#include <boost/fusion/iterator/next.hpp>
|
|
|
|
#include <boost/mpl/int.hpp>
|
|
|
|
#include <boost/mpl/identity.hpp>
|
|
|
|
|
|
|
|
namespace boost { namespace fusion
|
|
|
|
{
|
|
|
|
struct fusion_sequence_tag;
|
|
|
|
}}
|
|
|
|
|
|
|
|
namespace boost { namespace fusion { namespace detail
|
|
|
|
{
|
|
|
|
struct map_impl_from_iterator {};
|
|
|
|
|
|
|
|
template <int index, typename ...T>
|
|
|
|
struct map_impl;
|
|
|
|
|
|
|
|
template <int index_>
|
|
|
|
struct map_impl<index_>
|
|
|
|
{
|
|
|
|
typedef fusion_sequence_tag tag;
|
|
|
|
static int const index = index_;
|
|
|
|
static int const size = 0;
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
map_impl() {}
|
|
|
|
|
|
|
|
template <typename Iterator>
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2014-10-09 14:17:17 +02:00
|
|
|
map_impl(Iterator const&, map_impl_from_iterator)
|
2013-02-04 03:49:34 +00:00
|
|
|
{}
|
|
|
|
|
2013-02-04 06:21:45 +00:00
|
|
|
template <typename Iterator>
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2014-10-09 14:17:17 +02:00
|
|
|
void assign(Iterator const&, map_impl_from_iterator)
|
2013-02-04 06:21:45 +00:00
|
|
|
{}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
void get();
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
void get_val();
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
void get_key();
|
|
|
|
};
|
|
|
|
|
|
|
|
template <int index_, typename Pair, typename ...T>
|
|
|
|
struct map_impl<index_, Pair, T...> : map_impl<index_ + 1, T...>
|
|
|
|
{
|
|
|
|
typedef fusion_sequence_tag tag;
|
|
|
|
typedef map_impl<index_+1, T...> rest_type;
|
|
|
|
|
|
|
|
using rest_type::get;
|
|
|
|
using rest_type::get_val;
|
|
|
|
using rest_type::get_key;
|
|
|
|
|
|
|
|
static int const index = index_;
|
|
|
|
static int const size = rest_type::size + 1;
|
|
|
|
|
|
|
|
typedef Pair pair_type;
|
|
|
|
typedef typename Pair::first_type key_type;
|
|
|
|
typedef typename Pair::second_type value_type;
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
map_impl()
|
|
|
|
: rest_type(), element()
|
|
|
|
{}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
map_impl(map_impl const& rhs)
|
|
|
|
: rest_type(rhs.get_base()), element(rhs.element)
|
|
|
|
{}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
map_impl(map_impl&& rhs)
|
2014-03-18 23:43:23 +08:00
|
|
|
: rest_type(std::forward<rest_type>(*static_cast<rest_type*>(&rhs)))
|
2013-02-04 03:49:34 +00:00
|
|
|
, element(std::forward<Pair>(rhs.element))
|
|
|
|
{}
|
|
|
|
|
|
|
|
template <typename ...U>
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
map_impl(map_impl<index, U...> const& rhs)
|
|
|
|
: rest_type(rhs.get_base()), element(rhs.element)
|
|
|
|
{}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-10-05 18:47:44 +00:00
|
|
|
map_impl(typename detail::call_param<Pair>::type element_
|
2013-02-04 03:49:34 +00:00
|
|
|
, typename detail::call_param<T>::type... rest)
|
2013-10-05 18:47:44 +00:00
|
|
|
: rest_type(rest...), element(element_)
|
2013-02-04 03:49:34 +00:00
|
|
|
{}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-10-05 18:47:44 +00:00
|
|
|
map_impl(Pair&& element_, T&&... rest)
|
2013-02-04 03:49:34 +00:00
|
|
|
: rest_type(std::forward<T>(rest)...)
|
2013-10-05 18:47:44 +00:00
|
|
|
, element(std::forward<Pair>(element_))
|
2013-02-04 03:49:34 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
template <typename Iterator>
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
map_impl(Iterator const& iter, map_impl_from_iterator fi)
|
|
|
|
: rest_type(fusion::next(iter), fi)
|
|
|
|
, element(*iter)
|
|
|
|
{}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
rest_type& get_base()
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
rest_type const& get_base() const
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
value_type get_val(mpl::identity<key_type>);
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
pair_type get_val(mpl::int_<index>);
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
value_type get_val(mpl::identity<key_type>) const;
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
pair_type get_val(mpl::int_<index>) const;
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-05-13 23:01:05 +00:00
|
|
|
mpl::identity<key_type> get_key(mpl::int_<index>);
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-05-13 23:01:05 +00:00
|
|
|
mpl::identity<key_type> get_key(mpl::int_<index>) const;
|
2013-02-04 03:49:34 +00:00
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
typename cref_result<value_type>::type
|
|
|
|
get(mpl::identity<key_type>) const
|
|
|
|
{
|
|
|
|
return element.second;
|
|
|
|
}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
typename ref_result<value_type>::type
|
|
|
|
get(mpl::identity<key_type>)
|
|
|
|
{
|
|
|
|
return element.second;
|
|
|
|
}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
typename cref_result<pair_type>::type
|
|
|
|
get(mpl::int_<index>) const
|
|
|
|
{
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
typename ref_result<pair_type>::type
|
|
|
|
get(mpl::int_<index>)
|
|
|
|
{
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename ...U>
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
map_impl& operator=(map_impl<index, U...> const& rhs)
|
|
|
|
{
|
|
|
|
rest_type::operator=(rhs);
|
|
|
|
element = rhs.element;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
map_impl& operator=(map_impl const& rhs)
|
|
|
|
{
|
|
|
|
rest_type::operator=(rhs);
|
|
|
|
element = rhs.element;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 03:49:34 +00:00
|
|
|
map_impl& operator=(map_impl&& rhs)
|
|
|
|
{
|
|
|
|
rest_type::operator=(std::forward<map_impl>(rhs));
|
|
|
|
element = std::forward<Pair>(rhs.element);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-02-04 06:21:45 +00:00
|
|
|
template <typename Iterator>
|
2014-01-09 17:58:06 -08:00
|
|
|
BOOST_FUSION_GPU_ENABLED
|
2013-02-04 06:21:45 +00:00
|
|
|
void assign(Iterator const& iter, map_impl_from_iterator fi)
|
|
|
|
{
|
|
|
|
rest_type::assign(fusion::next(iter), fi);
|
|
|
|
element = *iter;
|
|
|
|
}
|
|
|
|
|
2013-02-04 03:49:34 +00:00
|
|
|
Pair element;
|
|
|
|
};
|
|
|
|
}}}
|
|
|
|
|
|
|
|
#endif
|