123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- /*=============================================================================
- Copyright (c) 2014-2015 Kohei Takahashi
- 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)
- # include <boost/fusion/container/set/detail/cpp03/set.hpp>
- #else
- ///////////////////////////////////////////////////////////////////////////////
- // C++11 interface
- ///////////////////////////////////////////////////////////////////////////////
- #include <boost/fusion/support/detail/access.hpp>
- #include <boost/fusion/support/void.hpp>
- #include <boost/fusion/support/detail/enabler.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>, detail::enabler_>::type = detail::enabler,
- typename enable_if<detail::is_same_size<Sequence, storage_type>, detail::enabler_>::type = detail::enabler)
- : 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() {}
- template <typename Sequence>
- BOOST_FUSION_GPU_ENABLED
- set(Sequence&& rhs,
- typename enable_if<traits::is_sequence<Sequence>, detail::enabler_>::type = detail::enabler,
- typename enable_if<detail::is_same_size<Sequence, storage_type>, detail::enabler_>::type = detail::enabler)
- : data(std::forward<Sequence>(rhs)) {}
- template <typename ...U>
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- explicit
- set(U&& ...args)
- : data(std::forward<U>(args)...) {}
- 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
- #endif
|