diff --git a/include/boost/fusion/container/generation/make_set.hpp b/include/boost/fusion/container/generation/make_set.hpp index 705ec582..7f98532b 100644 --- a/include/boost/fusion/container/generation/make_set.hpp +++ b/include/boost/fusion/container/generation/make_set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + 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) @@ -10,7 +10,37 @@ #include #include +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct make_set + { + typedef set::type...> type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::make_set::type + make_set(T const&... arg) + { + return typename result_of::make_set::type(arg...); + } + }} + #endif +#endif diff --git a/include/boost/fusion/container/set/detail/as_set.hpp b/include/boost/fusion/container/set/detail/as_set.hpp index 1eb0d3fe..9d333258 100644 --- a/include/boost/fusion/container/set/detail/as_set.hpp +++ b/include/boost/fusion/container/set/detail/as_set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + 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) @@ -13,7 +13,55 @@ /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ +BOOST_FUSION_BARRIER_BEGIN + + template ::type> + struct as_set; + + template + struct as_set > + { + template + struct apply + { + typedef set< + typename result_of::value_of< + typename result_of::advance_c::type + >::type... + > type; + }; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static typename apply::type + call(Iterator const& i) + { + typedef apply gen; + typedef typename gen::type result; + return result(*advance_c(i)...); + } + }; + +BOOST_FUSION_BARRIER_END +}}} #endif +#endif diff --git a/include/boost/fusion/container/set/detail/convert_impl.hpp b/include/boost/fusion/container/set/detail/convert_impl.hpp index d9d5dcfc..0b4cb22f 100644 --- a/include/boost/fusion/container/set/detail/convert_impl.hpp +++ b/include/boost/fusion/container/set/detail/convert_impl.hpp @@ -29,7 +29,7 @@ namespace boost { namespace fusion template struct apply { - typedef typename detail::as_set::value> gen; + typedef detail::as_set::value> gen; typedef typename gen:: template apply::type>::type type; diff --git a/include/boost/fusion/container/set/set.hpp b/include/boost/fusion/container/set/set.hpp index 59f4eafc..0d93290b 100644 --- a/include/boost/fusion/container/set/set.hpp +++ b/include/boost/fusion/container/set/set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + 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) @@ -13,8 +13,145 @@ /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct fusion_sequence_tag; + + template <> + struct set<> : sequence_base > + { + 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 + BOOST_FUSION_GPU_ENABLED + set(Sequence const& rhs) + : data(rhs) {} + + template + 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 + struct set : sequence_base > + { + 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 typename storage_type::size size; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set() + : data() {} + + template + BOOST_FUSION_GPU_ENABLED + set(Sequence const& rhs) + : data(rhs) {} + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template + BOOST_FUSION_GPU_ENABLED + set(Sequence&& rhs) + : data(std::forward(rhs)) {} +#endif + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + set(typename detail::call_param::type ...args) + : data(args...) {} + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + set(U&& ...args) + : data(std::forward(args)...) {} +#endif + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set& + operator=(U const& rhs) + { + data = rhs; + return *this; + } + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set& + operator=(U&& rhs) + { + data = std::forward(rhs); + return *this; + } +#endif + + 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 diff --git a/include/boost/fusion/container/set/set_fwd.hpp b/include/boost/fusion/container/set/set_fwd.hpp index 50d8d1c8..7b5d6830 100644 --- a/include/boost/fusion/container/set/set_fwd.hpp +++ b/include/boost/fusion/container/set/set_fwd.hpp @@ -9,11 +9,38 @@ #include #include +#include + +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) \ + || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +# if defined(BOOST_FUSION_HAS_VARIADIC_SET) +# undef BOOST_FUSION_HAS_VARIADIC_SET +# endif +#else +# if !defined(BOOST_FUSION_HAS_VARIADIC_SET) +# define BOOST_FUSION_HAS_VARIADIC_SET +# endif +#endif /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + struct set_tag; + struct set_iterator_tag; + + template + struct set; +}} #endif +#endif