Files
boost_fusion/include/boost/fusion/container/set/set.hpp

139 lines
4.5 KiB
C++
Raw Normal View History

2015-06-17 01:40:45 +09:00
/*=============================================================================
2015-08-20 22:30:41 +09:00
Copyright (c) 2014-2015 Kohei Takahashi
2015-06-17 01:40:45 +09:00
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)
==============================================================================*/
#ifndef FUSION_SET_11062014_1726
#define FUSION_SET_11062014_1726
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/container/set/set_fwd.hpp>
///////////////////////////////////////////////////////////////////////////////
// Without variadics, we will use the PP version
///////////////////////////////////////////////////////////////////////////////
#if !defined(BOOST_FUSION_HAS_VARIADIC_SET)
2015-06-17 01:40:45 +09:00
# include <boost/fusion/container/set/detail/cpp03/set.hpp>
#else
2015-06-17 01:40:45 +09:00
///////////////////////////////////////////////////////////////////////////////
// C++11 interface
///////////////////////////////////////////////////////////////////////////////
#include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/support/sequence_base.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/support/detail/is_same_size.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/set/detail/begin_impl.hpp>
#include <boost/fusion/container/set/detail/end_impl.hpp>
#include <boost/fusion/container/set/detail/value_of_impl.hpp>
#include <boost/fusion/container/set/detail/deref_data_impl.hpp>
#include <boost/fusion/container/set/detail/deref_impl.hpp>
#include <boost/fusion/container/set/detail/key_of_impl.hpp>
#include <boost/fusion/container/set/detail/value_of_data_impl.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/core/enable_if.hpp>
namespace boost { namespace fusion
{
struct fusion_sequence_tag;
template <>
struct set<> : sequence_base<set<> >
{
struct category : forward_traversal_tag, associative_tag {};
typedef set_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef mpl::false_ is_view;
typedef vector<> storage_type;
typedef storage_type::size size;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
set()
: data() {}
template <typename Sequence>
BOOST_FUSION_GPU_ENABLED
set(Sequence const& rhs,
typename enable_if<traits::is_sequence<Sequence> >::type* = 0,
typename enable_if<detail::is_same_size<Sequence, storage_type> >::type* = 0)
: data(rhs) {}
template <typename T>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
set&
operator=(T const& rhs)
{
data = rhs;
return *this;
}
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
storage_type& get_data() { return data; }
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
storage_type const& get_data() const { return data; }
private:
storage_type data;
};
template <typename ...T>
struct set : sequence_base<set<T...> >
{
struct category : forward_traversal_tag, associative_tag {};
typedef set_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef mpl::false_ is_view;
typedef vector<T...> storage_type;
typedef typename storage_type::size size;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
set()
: data() {}
2015-08-20 22:30:41 +09:00
template <typename Sequence>
BOOST_FUSION_GPU_ENABLED
set(Sequence&& rhs,
typename enable_if<traits::is_sequence<Sequence> >::type* = 0,
typename enable_if<detail::is_same_size<Sequence, storage_type> >::type* = 0)
2015-08-20 22:30:41 +09:00
: data(std::forward<Sequence>(rhs)) {}
template <typename ...U>
2015-10-07 17:40:55 +09:00
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
2015-08-20 22:30:41 +09:00
explicit
set(U&& ...args)
: data(std::forward<U>(args)...) {}
2015-08-20 22:30:41 +09:00
template <typename U>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
set&
operator=(U&& rhs)
{
data = std::forward<U>(rhs);
return *this;
}
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
storage_type& get_data() { return data; }
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
storage_type const& get_data() const { return data; }
private:
storage_type data;
};
}}
#endif
2015-06-17 01:40:45 +09:00
#endif