diff --git a/include/boost/fusion/adapted/std_array.hpp b/include/boost/fusion/adapted/std_array.hpp new file mode 100644 index 00000000..64ae6460 --- /dev/null +++ b/include/boost/fusion/adapted/std_array.hpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2013 Mateusz Loskot + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY__01062013_1700) +#define BOOST_FUSION_STD_ARRAY__01062013_1700 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/include/boost/fusion/adapted/std_array/detail/array_size.hpp b/include/boost/fusion/adapted/std_array/detail/array_size.hpp new file mode 100644 index 00000000..2f839404 --- /dev/null +++ b/include/boost/fusion/adapted/std_array/detail/array_size.hpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2013 Mateusz Loskot + + 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_STD_ARRAY_ARRAY_SIZE_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_ARRAY_SIZE_01062013_1700 + +#include +#include + +namespace boost { namespace fusion +{ + namespace extension + { + template + struct std_array_size; + + template class Array, typename T, std::size_t N> + struct std_array_size> : std::integral_constant {}; + } +}} + +#endif diff --git a/include/boost/fusion/adapted/std_array/detail/at_impl.hpp b/include/boost/fusion/adapted/std_array/detail/at_impl.hpp new file mode 100644 index 00000000..6086264a --- /dev/null +++ b/include/boost/fusion/adapted/std_array/detail/at_impl.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY_AT_IMPL_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_AT_IMPL_01062013_1700 + +#include + +#include + +namespace boost { namespace fusion { + + struct std_array_tag; + + namespace extension + { + template + struct at_impl; + + template<> + struct at_impl + { + template + struct apply + { + typedef typename mpl::if_< + is_const, + typename Sequence::const_reference, + typename Sequence::reference>::type type; + + static type + call(Sequence& seq) + { + return seq[N::value]; + } + }; + }; + } +}} + +#endif diff --git a/include/boost/fusion/adapted/std_array/detail/begin_impl.hpp b/include/boost/fusion/adapted/std_array/detail/begin_impl.hpp new file mode 100644 index 00000000..c84082e3 --- /dev/null +++ b/include/boost/fusion/adapted/std_array/detail/begin_impl.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 2013 Mateusz Loskot + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY_BEGIN_OF_IMPL_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_BEGIN_OF_IMPL_01062013_1700 + +#include + +namespace boost { namespace fusion { + + struct std_array_tag; + + namespace extension + { + template + struct begin_impl; + + template <> + struct begin_impl + { + template + struct apply + { + typedef std_array_iterator type; + + static type + call(Sequence& v) + { + return type(v); + } + }; + }; + } +}} + +#endif diff --git a/include/boost/fusion/adapted/std_array/detail/category_of_impl.hpp b/include/boost/fusion/adapted/std_array/detail/category_of_impl.hpp new file mode 100644 index 00000000..b5fa0935 --- /dev/null +++ b/include/boost/fusion/adapted/std_array/detail/category_of_impl.hpp @@ -0,0 +1,35 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY_CATEGORY_OF_IMPL_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_CATEGORY_OF_IMPL_01062013_1700 + +#include + +namespace boost { namespace fusion { + + struct std_array_tag; + struct random_access_traversal_tag; + + namespace extension + { + template + struct category_of_impl; + + template<> + struct category_of_impl + { + template + struct apply + { + typedef random_access_traversal_tag type; + }; + }; + } +}} + +#endif diff --git a/include/boost/fusion/adapted/std_array/detail/end_impl.hpp b/include/boost/fusion/adapted/std_array/detail/end_impl.hpp new file mode 100644 index 00000000..b7b789ef --- /dev/null +++ b/include/boost/fusion/adapted/std_array/detail/end_impl.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2013 Mateusz Loskot + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY_END_OF_IMPL_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_END_OF_IMPL_01062013_1700 + +#include +#include +#include + +namespace boost { namespace fusion { + + struct std_array_tag; + + namespace extension + { + template + struct end_impl; + + template <> + struct end_impl + { + template + struct apply + { + typedef typename remove_const::type seq_type; + static int const size = std_array_size::value; + typedef std_array_iterator type; + + static type + call(Sequence& v) + { + return type(v); + } + }; + }; + } +}} + +#endif diff --git a/include/boost/fusion/adapted/std_array/detail/is_sequence_impl.hpp b/include/boost/fusion/adapted/std_array/detail/is_sequence_impl.hpp new file mode 100644 index 00000000..8308e838 --- /dev/null +++ b/include/boost/fusion/adapted/std_array/detail/is_sequence_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2013 Mateusz Loskot + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY_IS_SEQUENCE_IMPL_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_IS_SEQUENCE_IMPL_01062013_1700 + +#include + +namespace boost { namespace fusion { + + struct std_array_tag; + + namespace extension + { + template + struct is_sequence_impl; + + template<> + struct is_sequence_impl + { + template + struct apply : mpl::true_ {}; + }; + } +}} + +#endif diff --git a/include/boost/fusion/adapted/std_array/detail/is_view_impl.hpp b/include/boost/fusion/adapted/std_array/detail/is_view_impl.hpp new file mode 100644 index 00000000..89cd04cf --- /dev/null +++ b/include/boost/fusion/adapted/std_array/detail/is_view_impl.hpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2013 Mateusz Loskot + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY_IS_VIEW_IMPL_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_IS_VIEW_IMPL_01062013_1700 + +#include + +namespace boost { namespace fusion +{ + struct std_array_tag; + + namespace extension + { + template + struct is_view_impl; + + template<> + struct is_view_impl + { + template + struct apply : mpl::false_ + {}; + }; + } +}} + +#endif diff --git a/include/boost/fusion/adapted/std_array/detail/size_impl.hpp b/include/boost/fusion/adapted/std_array/detail/size_impl.hpp new file mode 100644 index 00000000..7df51b2a --- /dev/null +++ b/include/boost/fusion/adapted/std_array/detail/size_impl.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 2013 Mateusz Loskot + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY_SIZE_IMPL_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_SIZE_IMPL_01062013_1700 + +#include +#include + +namespace boost { namespace fusion { + + struct std_array_tag; + + namespace extension + { + template + struct size_impl; + + template<> + struct size_impl + { + template + struct apply + : mpl::int_ + < + std_array_size + < + typename remove_const::type + >::value + > + {}; + }; + } +}} + +#endif diff --git a/include/boost/fusion/adapted/std_array/detail/value_at_impl.hpp b/include/boost/fusion/adapted/std_array/detail/value_at_impl.hpp new file mode 100644 index 00000000..3d7871a7 --- /dev/null +++ b/include/boost/fusion/adapted/std_array/detail/value_at_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY_VALUE_AT_IMPL_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_VALUE_AT_IMPL_01062013_1700 + +namespace boost { namespace fusion { + + struct std_array_tag; + + namespace extension + { + template + struct value_at_impl; + + template <> + struct value_at_impl + { + template + struct apply + { + typedef typename Sequence::value_type type; + }; + }; + } +}} + +#endif diff --git a/include/boost/fusion/adapted/std_array/std_array_iterator.hpp b/include/boost/fusion/adapted/std_array/std_array_iterator.hpp new file mode 100644 index 00000000..29584512 --- /dev/null +++ b/include/boost/fusion/adapted/std_array/std_array_iterator.hpp @@ -0,0 +1,109 @@ +/*============================================================================= + Copyright (c) 2013 Mateusz Loskot + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY_ARRAY_ITERATOR_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_ARRAY_ITERATOR_01062013_1700 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct random_access_traversal_tag; + + template + struct std_array_iterator + : iterator_facade, random_access_traversal_tag> + { + BOOST_MPL_ASSERT_RELATION(Pos, >=, 0); + BOOST_MPL_ASSERT_RELATION(Pos, <=, std::tuple_size::value); + + typedef mpl::int_ index; + typedef Array array_type; + + std_array_iterator(Array& a) + : array(a) {} + + Array& array; + + template + struct value_of + { + typedef typename Iterator::array_type array_type; + typedef typename array_type::value_type type; + }; + + template + struct deref + { + typedef typename Iterator::array_type array_type; + typedef typename + mpl::if_< + is_const + , typename array_type::const_reference + , typename array_type::reference + >::type + type; + + static type + call(Iterator const & it) + { + return it.array[Iterator::index::value]; + } + }; + + template + struct advance + { + typedef typename Iterator::index index; + typedef typename Iterator::array_type array_type; + typedef std_array_iterator type; + + static type + call(Iterator const& i) + { + return type(i.array); + } + }; + + template + struct next : advance > {}; + + template + struct prior : advance > {}; + + template + struct distance : mpl::minus + { + typedef typename + mpl::minus< + typename I2::index, typename I1::index + >::type + type; + + static type + call(I1 const&, I2 const&) + { + return type(); + } + }; + + private: + + std_array_iterator& operator=(std_array_iterator const&); + }; +}} + +#endif diff --git a/include/boost/fusion/adapted/std_array/tag_of.hpp b/include/boost/fusion/adapted/std_array/tag_of.hpp new file mode 100644 index 00000000..543c5bb4 --- /dev/null +++ b/include/boost/fusion/adapted/std_array/tag_of.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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_STD_ARRAY_TAG_OF_01062013_1700) +#define BOOST_FUSION_STD_ARRAY_TAG_OF_01062013_1700 + +#include +#include +#include + +namespace boost { namespace fusion +{ + struct std_array_tag; + struct fusion_sequence_tag; + + namespace traits + { + template +#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) + struct tag_of, void > +#else + struct tag_of > +#endif + { + typedef std_array_tag type; + }; + } +}} + +namespace boost { namespace mpl +{ + template + struct sequence_tag; + + template + struct sequence_tag > + { + typedef fusion::fusion_sequence_tag type; + }; + + template + struct sequence_tag const> + { + typedef fusion::fusion_sequence_tag type; + }; +}} + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/define_struct.hpp b/include/boost/fusion/adapted/struct/detail/define_struct.hpp index ab483f02..cb52ddff 100644 --- a/include/boost/fusion/adapted/struct/detail/define_struct.hpp +++ b/include/boost/fusion/adapted/struct/detail/define_struct.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,8 @@ #define BOOST_FUSION_DEFINE_STRUCT_FILLER_0_END #define BOOST_FUSION_DEFINE_STRUCT_FILLER_1_END +#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + #define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I( \ R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE) \ \ @@ -46,6 +49,54 @@ BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)( \ other_self.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)) +#define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + \ + BOOST_FUSION_GPU_ENABLED \ + NAME(self_type const& other_self) \ + : BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I, \ + ATTRIBUTE_TUPLE_SIZE, \ + ATTRIBUTES_SEQ) \ + {} + +// Use templated version instead. +#define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_FILLER_I( \ + R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE) \ + \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)= \ + other.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE); + +#define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_OP( \ + ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + \ + BOOST_FUSION_GPU_ENABLED \ + self_type& operator=(self_type const& other) \ + { \ + BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_FILLER_I, \ + ATTRIBUTE_TUPLE_SIZE, \ + ATTRIBUTES_SEQ) \ + \ + return *this; \ + } + +#else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + +#define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + \ + BOOST_FUSION_GPU_ENABLED NAME(self_type const&) = default; + +#define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_OP( \ + ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + \ + BOOST_FUSION_GPU_ENABLED self_type& operator=(self_type const&) = default; + +#endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + #define BOOST_FUSION_DEFINE_STRUCT_ASSIGN_FILLER_I( \ R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE) \ \ @@ -85,6 +136,81 @@ return *this; \ } +#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES + +#define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR(NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) +#define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP(ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) + +#else // BOOST_NO_CXX11_RVALUE_REFERENCES + +#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \ + || BOOST_WORKAROUND(BOOST_GCC, < 40500) \ + || BOOST_WORKAROUND(BOOST_MSVC, == 1800) + +#define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR_FILLER_I( \ + R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE) \ + \ + BOOST_PP_COMMA_IF(I) \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)(std::move( \ + other_self.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE))) + +#define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + \ + BOOST_FUSION_GPU_ENABLED \ + NAME(self_type&& other_self) \ + : BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR_FILLER_I, \ + ATTRIBUTE_TUPLE_SIZE, \ + ATTRIBUTES_SEQ) \ + {} + +#else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + +#define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + \ + BOOST_FUSION_GPU_ENABLED NAME(self_type&&) = default; + +#endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + +#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \ + || BOOST_WORKAROUND(BOOST_GCC, < 40600) \ + || BOOST_WORKAROUND(BOOST_MSVC, == 1800) + +#define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_FILLER_I( \ + R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE) \ + \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)=std::move( \ + other.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)); + +#define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP( \ + ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + \ + BOOST_FUSION_GPU_ENABLED \ + self_type& operator=(self_type&& other) \ + { \ + BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_FILLER_I, \ + ATTRIBUTE_TUPLE_SIZE, \ + ATTRIBUTES_SEQ) \ + \ + return *this; \ + } + +#else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + +#define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP( \ + ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + \ + BOOST_FUSION_GPU_ENABLED self_type& operator=(self_type&&) = default; + +#endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + +#endif // BOOST_NO_CXX11_RVALUE_REFERENCES + #define BOOST_FUSION_DEFINE_STRUCT_ATTR_I(R, ATTRIBUTE_TUPLE_SIZE, ATTRIBUTE) \ \ BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,0,ATTRIBUTE) \ @@ -135,14 +261,10 @@ ATTRIBUTES_SEQ) \ {} \ \ - BOOST_FUSION_GPU_ENABLED \ - NAME(self_type const& other_self) \ - : BOOST_PP_SEQ_FOR_EACH_I_R( \ - 1, \ - BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I, \ - ATTRIBUTE_TUPLE_SIZE, \ - ATTRIBUTES_SEQ) \ - {} \ + BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ \ template \ BOOST_FUSION_GPU_ENABLED \ @@ -160,6 +282,10 @@ ATTRIBUTES_SEQ) \ {} \ \ + BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_OP( \ + ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP( \ + ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ BOOST_FUSION_DEFINE_STRUCT_ASSIGN_OP(ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) #define BOOST_FUSION_DEFINE_STRUCT_CTOR_1( \ @@ -282,20 +408,7 @@ NAME, BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ), ATTRIBUTE_TUPLE_SIZE) #define BOOST_FUSION_DEFINE_EMPTY_STRUCT_IMPL( \ - NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ - \ - template \ - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ - NAME(Seq const&) \ - {} \ - \ - template \ - BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ - self_type& \ - operator=(Seq const& seq) \ - { \ - return *this; \ - } + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) #define BOOST_FUSION_DEFINE_STRUCT_IMPL( \ NAMESPACE_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ @@ -327,10 +440,7 @@ ATTRIBUTE_TUPLE_SIZE) #define BOOST_FUSION_DEFINE_EMPTY_TPL_STRUCT_IMPL( \ - TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ - \ - BOOST_FUSION_DEFINE_EMPTY_STRUCT_IMPL( \ - NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) + TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) #define BOOST_FUSION_DEFINE_TPL_STRUCT_IMPL( \ TEMPLATE_PARAMS_SEQ, \ diff --git a/include/boost/fusion/container/deque/detail/keyed_element.hpp b/include/boost/fusion/container/deque/detail/keyed_element.hpp index 24b5979d..15b68667 100644 --- a/include/boost/fusion/container/deque/detail/keyed_element.hpp +++ b/include/boost/fusion/container/deque/detail/keyed_element.hpp @@ -59,7 +59,7 @@ namespace boost { namespace fusion { namespace detail #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED keyed_element(keyed_element&& rhs) - : Rest(BOOST_FUSION_FWD_ELEM(Rest, rhs.forward_base())) + : Rest(rhs.forward_base()) , value_(BOOST_FUSION_FWD_ELEM(Value, rhs.value_)) {} #endif @@ -90,7 +90,7 @@ namespace boost { namespace fusion { namespace detail BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED Rest&& forward_base() BOOST_NOEXCEPT { - return BOOST_FUSION_FWD_ELEM(Rest, *static_cast(this)); + return std::move(*static_cast(this)); } #endif @@ -116,7 +116,7 @@ namespace boost { namespace fusion { namespace detail #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED keyed_element(Value&& value, Rest&& rest) - : Rest(BOOST_FUSION_FWD_ELEM(Rest, rest)) + : Rest(std::move(rest)) , value_(BOOST_FUSION_FWD_ELEM(Value, value)) {} #endif @@ -147,8 +147,8 @@ namespace boost { namespace fusion { namespace detail BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED keyed_element& operator=(keyed_element&& rhs) { - base::operator=(std::forward(rhs)); - value_ = BOOST_FUSION_FWD_ELEM(Value, rhs.value_); + base::operator=(rhs.forward_base()); + value_ = std::move(rhs.value_); return *this; } #endif diff --git a/include/boost/fusion/container/vector/detail/config.hpp b/include/boost/fusion/container/vector/detail/config.hpp index 84f4605d..2a7aea64 100644 --- a/include/boost/fusion/container/vector/detail/config.hpp +++ b/include/boost/fusion/container/vector/detail/config.hpp @@ -15,6 +15,8 @@ || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \ || defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) \ || defined(BOOST_NO_CXX11_DECLTYPE)) \ + || defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) \ + || defined(BOOST_FUSION_DISABLE_VARIADIC_VECTOR) \ || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) # if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # undef BOOST_FUSION_HAS_VARIADIC_VECTOR diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index 65bffd0b..62d2445e 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -24,23 +24,21 @@ /////////////////////////////////////////////////////////////////////////////// #include #include -#include -#include +#include #include #include #include #include #include -#include #include +#include #include #include #include #include -#include -#include +#include +#include #include -#include #include #include #include @@ -53,52 +51,48 @@ namespace boost { namespace fusion namespace vector_detail { struct each_elem {}; - struct copy_or_move {}; - template struct from_sequence {}; - template - struct make_indices_from_seq - : detail::make_index_sequence< - fusion::result_of::size::type>::value + template < + typename This, typename T, typename T_, std::size_t Size, bool IsSeq + > + struct can_convert_impl : false_type {}; + + template + struct can_convert_impl : true_type {}; + + template + struct can_convert_impl + : integral_constant< + bool + , !is_convertible< + Sequence + , typename fusion::extension::value_at_impl:: + template apply< This, mpl::int_<0> >::type + >::value > {}; - template - struct pure : remove_cv::type> {}; - - template ::value> - struct is_convertible_to_first - : boost::is_convertible::type> + template + struct can_convert + : can_convert_impl< + This, T, T_, Size, traits::is_sequence::value + > {}; - template - struct is_convertible_to_first - : mpl::false_ + template + struct is_longer_sequence_impl : false_type {}; + + template + struct is_longer_sequence_impl + : integral_constant< + bool, (fusion::result_of::size::value >= Size) + > {}; - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline each_elem - dispatch(T const&...) BOOST_NOEXCEPT { return each_elem(); } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline copy_or_move - dispatch(This const&) BOOST_NOEXCEPT { return copy_or_move(); } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline from_sequence< - typename lazy_enable_if_c< - (traits::is_sequence::type>::value && - !is_same::type>::value && - !is_convertible_to_first::value) - , make_indices_from_seq - >::type - > - dispatch(Sequence&&) BOOST_NOEXCEPT - { return from_sequence::type>(); } - + template + struct is_longer_sequence + : is_longer_sequence_impl::value, Size> + {}; // forward_at_c allows to access Nth element even if ForwardSequence // since fusion::at_c requires RandomAccessSequence. @@ -163,22 +157,17 @@ namespace boost { namespace fusion return *this; } - template + template < + typename U + , typename = typename boost::disable_if< + is_base_of::type> + >::type + > BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - store(U&& rhs - , typename disable_if::type, store>, detail::enabler_>::type = detail::enabler) + store(U&& rhs) : elem(std::forward(rhs)) {} - template - BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - typename disable_if::type, store>, store&>::type - operator=(U&& rhs) - { - elem = std::forward(rhs); - return *this; - } - BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED T & get() { return elem; } BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -206,21 +195,17 @@ namespace boost { namespace fusion vector_data() {} - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - vector_data(copy_or_move, vector_data const& rhs) - : store(static_cast const&>(rhs))... - {} - - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - vector_data(copy_or_move, vector_data&& rhs) - : store(std::forward >(rhs))... - {} - - template + template < + typename Sequence + , typename Sequence_ = typename remove_reference::type + , typename = typename boost::enable_if< + can_convert + >::type + > BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit - vector_data(from_sequence >, Sequence&& rhs) - : store(forward_at_c(rhs))... + vector_data(each_elem, Sequence&& rhs) + : store(forward_at_c(std::forward(rhs)))... {} template @@ -230,6 +215,14 @@ namespace boost { namespace fusion : store(std::forward(var))... {} + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + void + assign_sequence(Sequence&& seq) + { + assign(std::forward(seq), detail::index_sequence()); + } + template BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED void @@ -294,15 +287,36 @@ namespace boost { namespace fusion vector() {} - // rvalue-references is required here in order to forward any arguments to - // base: vector(T const&...) doesn't work with trailing void_ and - // vector(U const&...) cannot forward any arguments to base. - template + template < + typename... U + , typename = typename boost::enable_if_c<( + sizeof...(U) >= 1 && + fusion::detail::and_...>::value && + !fusion::detail::and_< + is_base_of::type>... + >::value + )>::type + > // XXX: constexpr become error due to pull-request #79, booooo!! // In the (near) future release, should be fixed. /* BOOST_CONSTEXPR */ BOOST_FUSION_GPU_ENABLED - vector(U&&... u) - : base(vector_detail::dispatch(std::forward(u)...), std::forward(u)...) + explicit vector(U&&... u) + : base(vector_detail::each_elem(), std::forward(u)...) + {} + + template < + typename Sequence + , typename Sequence_ = typename remove_reference::type + , typename = typename boost::enable_if_c<( + !is_base_of::value && + vector_detail::is_longer_sequence< + Sequence_, sizeof...(T) + >::value + )>::type + > + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector(Sequence&& seq) + : base(vector_detail::each_elem(), std::forward(seq)) {} template @@ -310,10 +324,7 @@ namespace boost { namespace fusion vector& operator=(Sequence&& rhs) { - typedef typename - vector_detail::make_indices_from_seq::type - indices; - base::assign(std::forward(rhs), indices()); + base::assign_sequence(std::forward(rhs)); return *this; } }; diff --git a/include/boost/fusion/support/detail/and.hpp b/include/boost/fusion/support/detail/and.hpp new file mode 100644 index 00000000..1b310dda --- /dev/null +++ b/include/boost/fusion/support/detail/and.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2016 Lee Clagett + + 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_AND_07152016_1625 +#define FUSION_AND_07152016_1625 + +#include +#include + +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#error fusion::detail::and_ requires variadic templates +#endif + +namespace boost { namespace fusion { namespace detail { + template + struct and_impl : false_type {}; + + template + struct and_impl...> : true_type {}; + + // This specialization is necessary to avoid MSVC-12 variadics bug. + template + struct and_impl1 : and_impl...> {}; + + /* fusion::detail::and_ differs from mpl::and_ in the following ways: + - The empty set is valid and returns true + - A single element set is valid and returns the identity + - There is no upper bound on the set size + - The conditions are evaluated at once, and are not short-circuited. This + reduces instantations when returning true; the implementation is not + recursive. */ + template + struct and_ : and_impl1 {}; +}}} + +#endif // FUSION_AND_07152016_1625 diff --git a/include/boost/fusion/tuple/tuple.hpp b/include/boost/fusion/tuple/tuple.hpp index 6ee21f56..07014c6c 100644 --- a/include/boost/fusion/tuple/tuple.hpp +++ b/include/boost/fusion/tuple/tuple.hpp @@ -20,12 +20,15 @@ /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// +#include #include #include #include #include #include #include +#include +#include #include namespace boost { namespace fusion @@ -39,23 +42,49 @@ namespace boost { namespace fusion tuple() : base_type() {} - template + template < + typename ...U + , typename = typename boost::enable_if_c< + sizeof...(U) >= sizeof...(T) + >::type + > BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED tuple(tuple const& other) : base_type(other) {} - template + template < + typename ...U + , typename = typename boost::enable_if_c< + sizeof...(U) >= sizeof...(T) + >::type + > BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED tuple(tuple&& other) : base_type(std::move(other)) {} - template + template < + typename ...U + , typename = typename boost::enable_if_c<( + fusion::detail::and_...>::value && + sizeof...(U) >= 1 + )>::type + > /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED explicit tuple(U&&... args) : base_type(std::forward(args)...) {} - template + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple(std::pair const& other) + : base_type(other.first, other.second) {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple(std::pair&& other) + : base_type(std::move(other.first), std::move(other.second)) {} + + template BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED tuple& operator=(U&& rhs) { diff --git a/include/boost/fusion/view/zip_view/zip_view.hpp b/include/boost/fusion/view/zip_view/zip_view.hpp index cf6f6d27..b0327201 100644 --- a/include/boost/fusion/view/zip_view/zip_view.hpp +++ b/include/boost/fusion/view/zip_view/zip_view.hpp @@ -126,7 +126,7 @@ namespace boost { namespace fusion { zip_view( const Sequences& seqs) : sequences_(seqs) - {}; + {} sequences sequences_; }; diff --git a/test/Jamfile b/test/Jamfile index 8f290165..017e8922 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,5 +1,6 @@ ##============================================================================== # Copyright (c) 2003-2006 Joel de Guzman +# Copyright (c) 2013 Mateusz Loskot # # Use, modification and distribution is subject to the Boost Software # License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -121,8 +122,10 @@ project [ run sequence/std_pair.cpp : : : : ] [ run sequence/boost_array.cpp : : : : ] [ run sequence/array.cpp : : : : ] + [ run sequence/std_array.cpp : : : : ] [ run sequence/tuple_comparison.cpp : : : : ] [ run sequence/tuple_construction.cpp : : : : ] + [ run sequence/tuple_conversion.cpp : : : : ] [ run sequence/tuple_copy.cpp : : : : ] [ run sequence/tuple_element.cpp : : : : ] [ run sequence/tuple_make.cpp : : : : ] @@ -131,9 +134,24 @@ project [ run sequence/tuple_nest.cpp : : : : ] [ run sequence/tuple_hash.cpp : : : : ] [ run sequence/tuple_tie.cpp : : : : ] + [ + run sequence/tuple_traits.cpp + : + : + : + : sequence/tuple_traits/maybe_variadic_tuple + ] + [ + run sequence/tuple_traits.cpp + : + : + : BOOST_FUSION_DISABLE_VARIADIC_VECTOR + : sequence/tuple_traits/no_variadic_tuple + ] [ run sequence/transform_view.cpp : : : : ] [ run sequence/vector_comparison.cpp : : : : ] [ run sequence/vector_construction.cpp : : : : ] + [ run sequence/vector_conversion.cpp : : : : ] [ run sequence/vector_copy.cpp : : : : ] [ run sequence/vector_iterator.cpp : : : : ] [ run sequence/vector_make.cpp : : : : ] @@ -144,6 +162,20 @@ project [ run sequence/vector_nest.cpp : : : : ] [ run sequence/vector_hash.cpp : : : : ] [ run sequence/vector_tie.cpp : : : : ] + [ + run sequence/vector_traits.cpp + : + : + : + : sequence/vector_traits/maybe_variadic_vector + ] + [ + run sequence/vector_traits.cpp + : + : + : BOOST_FUSION_DISABLE_VARIADIC_VECTOR + : sequence/vector_traits/no_variadic_vector + ] [ run sequence/vector_value_at.cpp : : : : ] [ run sequence/zip_view.cpp : : : : ] [ run sequence/zip_view2.cpp : : : : ] @@ -151,24 +183,48 @@ project [ run sequence/repetitive_view.cpp : : : : ] [ run sequence/deduce_sequence.cpp : : : : ] [ run sequence/adapt_adt_named.cpp : : : : ] + [ run sequence/adapt_adt_named_empty.cpp : : : : ] [ run sequence/adapt_adt.cpp : : : : ] + [ run sequence/adapt_adt_empty.cpp : : : : ] [ run sequence/adapt_assoc_adt_named.cpp : : : : ] + [ run sequence/adapt_assoc_adt_named_empty.cpp : : : : ] [ run sequence/adapt_assoc_adt.cpp : : : : ] + [ run sequence/adapt_assoc_adt_empty.cpp : : : : ] [ run sequence/adapt_assoc_struct_named.cpp : : : : ] + [ run sequence/adapt_assoc_struct_named_empty.cpp : : : : ] [ run sequence/adapt_assoc_struct.cpp : : : : ] + [ run sequence/adapt_assoc_struct_empty.cpp : : : : ] [ run sequence/adapt_assoc_tpl_adt.cpp : : : : ] + [ run sequence/adapt_assoc_tpl_adt_empty.cpp : : : : ] [ run sequence/adapt_assoc_tpl_struct.cpp : : : : ] + [ run sequence/adapt_assoc_tpl_struct_empty.cpp : : : : ] [ run sequence/adapt_struct_named.cpp : : : : ] + [ run sequence/adapt_struct_named_empty.cpp : : : : ] [ run sequence/adapt_struct.cpp : : : : ] + [ run sequence/adapt_struct_empty.cpp : : : : ] [ run sequence/adapt_tpl_adt.cpp : : : : ] + [ run sequence/adapt_tpl_adt_empty.cpp : : : : ] [ run sequence/adapt_tpl_struct.cpp : : : : ] + [ run sequence/adapt_tpl_struct_empty.cpp : : : : ] [ run sequence/adt_attribute_proxy.cpp : : : : ] [ run sequence/define_struct.cpp : : : : ] + [ run sequence/define_struct_empty.cpp : : : : ] + [ run sequence/define_struct_move.cpp : : : : ] [ run sequence/define_struct_inline.cpp : : : : ] + [ run sequence/define_struct_inline_empty.cpp : : : : ] + [ run sequence/define_struct_inline_move.cpp : : : : ] [ run sequence/define_assoc_struct.cpp : : : : ] + [ run sequence/define_assoc_struct_empty.cpp : : : : ] + [ run sequence/define_assoc_struct_move.cpp : : : : ] [ run sequence/define_tpl_struct.cpp : : : : ] + [ run sequence/define_tpl_struct_empty.cpp : : : : ] + [ run sequence/define_tpl_struct_move.cpp : : : : ] [ run sequence/define_tpl_struct_inline.cpp : : : : ] + [ run sequence/define_tpl_struct_inline_empty.cpp : : : : ] + [ run sequence/define_tpl_struct_inline_move.cpp : : : : ] [ run sequence/define_assoc_tpl_struct.cpp : : : : ] + [ run sequence/define_assoc_tpl_struct_empty.cpp : : : : ] + [ run sequence/define_assoc_tpl_struct_move.cpp : : : : ] [ run sequence/std_tuple.cpp : : : : ] [ run sequence/std_tuple_iterator.cpp : : : : ] [ run sequence/ref_vector.cpp : : : : ] @@ -197,6 +253,7 @@ project [ compile support/pair_vector.cpp : : : : ] [ compile support/pair_nest.cpp : : : : ] [ compile support/index_sequence.cpp : : : : ] + [ compile support/and.cpp : : : : ] # [ compile-fail xxx.cpp : : : : ] diff --git a/test/sequence/adapt_adt_empty.cpp b/test/sequence/adapt_adt_empty.cpp new file mode 100644 index 00000000..925cdce0 --- /dev/null +++ b/test/sequence/adapt_adt_empty.cpp @@ -0,0 +1,86 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class empty_adt{}; +BOOST_FUSION_ADAPT_ADT(empty_adt,) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + empty_adt e; + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin::type, + fusion::result_of::end::type>)); + } + + { + fusion::vector<> v; + empty_adt e; + BOOST_TEST(v == e); + BOOST_TEST_NOT(v != e); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + empty_adt e; + + // conversion from empty_adt to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_adt to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_adt_named_empty.cpp b/test/sequence/adapt_adt_named_empty.cpp new file mode 100644 index 00000000..f750071d --- /dev/null +++ b/test/sequence/adapt_adt_named_empty.cpp @@ -0,0 +1,87 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class empty_adt{}; +BOOST_FUSION_ADAPT_ADT_NAMED(::empty_adt,empty_adt,) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + empty_adt empty; + { + BOOST_MPL_ASSERT((traits::is_view)); + adapted::empty_adt e(empty); + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin::type, + fusion::result_of::end::type>)); + } + + { + fusion::vector<> v; + adapted::empty_adt e(empty); + BOOST_TEST(v == e); + BOOST_TEST_NOT(v != e); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + adapted::empty_adt e(empty); + + // conversion from empty_adt to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_adt to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_assoc_adt_empty.cpp b/test/sequence/adapt_assoc_adt_empty.cpp new file mode 100644 index 00000000..8d4d2a28 --- /dev/null +++ b/test/sequence/adapt_assoc_adt_empty.cpp @@ -0,0 +1,88 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class empty_adt{}; +BOOST_FUSION_ADAPT_ASSOC_ADT(empty_adt,) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + empty_adt e; + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin::type, + fusion::result_of::end::type>)); + } + + { + fusion::vector<> v; + empty_adt e; + BOOST_TEST(v == e); + BOOST_TEST_NOT(e != v); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + empty_adt e; + + // conversion from empty_adt to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_adt to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_assoc_adt_named_empty.cpp b/test/sequence/adapt_assoc_adt_named_empty.cpp new file mode 100644 index 00000000..c8fa102a --- /dev/null +++ b/test/sequence/adapt_assoc_adt_named_empty.cpp @@ -0,0 +1,89 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class empty_adt{}; +BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(::empty_adt,empty_adt,) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + empty_adt empty; + { + BOOST_MPL_ASSERT((traits::is_view)); + adapted::empty_adt e(empty); + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin::type, + fusion::result_of::end::type>)); + } + + { + fusion::vector<> v; + adapted::empty_adt e(empty); + BOOST_TEST(v == e); + BOOST_TEST_NOT(e != v); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + adapted::empty_adt e(empty); + + // conversion from empty_adt to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_adt to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_assoc_struct_empty.cpp b/test/sequence/adapt_assoc_struct_empty.cpp new file mode 100644 index 00000000..aa75f87a --- /dev/null +++ b/test/sequence/adapt_assoc_struct_empty.cpp @@ -0,0 +1,88 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class empty_struct{}; +BOOST_FUSION_ADAPT_ASSOC_STRUCT(empty_struct,) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + empty_struct e; + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin::type, + fusion::result_of::end::type>)); + } + + { + fusion::vector<> v; + empty_struct e; + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + empty_struct e; + + // conversion from empty_struct to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_struct to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_assoc_struct_named_empty.cpp b/test/sequence/adapt_assoc_struct_named_empty.cpp new file mode 100644 index 00000000..a744d6a4 --- /dev/null +++ b/test/sequence/adapt_assoc_struct_named_empty.cpp @@ -0,0 +1,89 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class empty_struct{}; +BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(::empty_struct,empty_struct,) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + empty_struct empty; + { + BOOST_MPL_ASSERT((traits::is_view)); + adapted::empty_struct e(empty); + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin::type, + fusion::result_of::end::type>)); + } + + { + fusion::vector<> v; + adapted::empty_struct e(empty); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + adapted::empty_struct e(empty); + + // conversion from empty_struct to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_struct to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_assoc_tpl_adt_empty.cpp b/test/sequence/adapt_assoc_tpl_adt_empty.cpp new file mode 100644 index 00000000..f38ba7ac --- /dev/null +++ b/test/sequence/adapt_assoc_tpl_adt_empty.cpp @@ -0,0 +1,89 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +class empty_adt{}; +BOOST_FUSION_ADAPT_ASSOC_TPL_ADT((T), (empty_adt)(T),) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view >)); + empty_adt e; + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size >::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty >)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin >::type, + fusion::result_of::end >::type>)); + } + + { + fusion::vector<> v; + empty_adt e; + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + empty_adt e; + + // conversion from empty_adt to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_adt to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence >)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key, void>)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key, int>)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_assoc_tpl_struct_empty.cpp b/test/sequence/adapt_assoc_tpl_struct_empty.cpp new file mode 100644 index 00000000..42795c41 --- /dev/null +++ b/test/sequence/adapt_assoc_tpl_struct_empty.cpp @@ -0,0 +1,89 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +class empty_struct{}; +BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT((T), (empty_struct)(T),) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view >)); + empty_struct e; + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size >::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty >)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin >::type, + fusion::result_of::end >::type>)); + } + + { + fusion::vector<> v; + empty_struct e; + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + empty_struct e; + + // conversion from empty_struct to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_struct to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence >)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key, void>)); + BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key, int>)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_struct_empty.cpp b/test/sequence/adapt_struct_empty.cpp new file mode 100644 index 00000000..f08dc98d --- /dev/null +++ b/test/sequence/adapt_struct_empty.cpp @@ -0,0 +1,86 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class empty_struct{}; +BOOST_FUSION_ADAPT_STRUCT(empty_struct,) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + empty_struct e; + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin::type, + fusion::result_of::end::type>)); + } + + { + fusion::vector<> v; + empty_struct e; + BOOST_TEST(v == e); + BOOST_TEST_NOT(e != v); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + empty_struct e; + + // conversion from empty_struct to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_struct to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_struct_named_empty.cpp b/test/sequence/adapt_struct_named_empty.cpp new file mode 100644 index 00000000..8333f130 --- /dev/null +++ b/test/sequence/adapt_struct_named_empty.cpp @@ -0,0 +1,87 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class empty_struct{}; +BOOST_FUSION_ADAPT_STRUCT_NAMED(::empty_struct,empty_struct,) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + empty_struct empty; + { + BOOST_MPL_ASSERT((traits::is_view)); + adapted::empty_struct e(empty); + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin::type, + fusion::result_of::end::type>)); + } + + { + fusion::vector<> v; + adapted::empty_struct e(empty); + BOOST_TEST(v == e); + BOOST_TEST_NOT(e != v); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + adapted::empty_struct e(empty); + + // conversion from empty_struct to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_struct to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_tpl_adt_empty.cpp b/test/sequence/adapt_tpl_adt_empty.cpp new file mode 100644 index 00000000..82bf2121 --- /dev/null +++ b/test/sequence/adapt_tpl_adt_empty.cpp @@ -0,0 +1,87 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +class empty_adt{}; +BOOST_FUSION_ADAPT_TPL_ADT((T), (empty_adt)(T),) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view >)); + empty_adt e; + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size >::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty >)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin >::type, + fusion::result_of::end >::type>)); + } + + { + fusion::vector<> v; + empty_adt e; + BOOST_TEST(v == e); + BOOST_TEST_NOT(v != e); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(e > v); + BOOST_TEST(e >= v); + } + + { + empty_adt e; + + // conversion from empty_adt to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_adt to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence >)); + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_tpl_struct_empty.cpp b/test/sequence/adapt_tpl_struct_empty.cpp new file mode 100644 index 00000000..5cb1d442 --- /dev/null +++ b/test/sequence/adapt_tpl_struct_empty.cpp @@ -0,0 +1,87 @@ +/*============================================================================= + Copyright (c) 2016 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) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +class empty_struct{}; +BOOST_FUSION_ADAPT_TPL_STRUCT((T), (empty_struct)(T),) + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view >)); + empty_struct e; + + std::cout << e << std::endl; + BOOST_TEST(e == make_vector()); + + BOOST_STATIC_ASSERT(fusion::result_of::size >::value == 0); + BOOST_MPL_ASSERT((fusion::result_of::empty >)); + + BOOST_MPL_ASSERT((fusion::result_of::equal_to< + fusion::result_of::begin >::type, + fusion::result_of::end >::type>)); + } + + { + fusion::vector<> v; + empty_struct e; + BOOST_TEST(v == e); + BOOST_TEST_NOT(v != e); + BOOST_TEST_NOT(v < e); + BOOST_TEST(v <= e); + BOOST_TEST_NOT(v > e); + BOOST_TEST(v >= e); + } + + { + empty_struct e; + + // conversion from empty_struct to vector + fusion::vector<> v(e); + v = e; + + // FIXME + // conversion from empty_struct to list + //fusion::list<> l(e); + //l = e; + } + + BOOST_MPL_ASSERT((mpl::is_sequence >)); + + return boost::report_errors(); +} + diff --git a/test/sequence/conversion.hpp b/test/sequence/conversion.hpp new file mode 100644 index 00000000..f5720776 --- /dev/null +++ b/test/sequence/conversion.hpp @@ -0,0 +1,322 @@ +/*============================================================================= + Copyright (c) 2016 Lee Clagett + + Use modification and distribution are subject to the Boost Software + License, Version 1.0. (See accompanyintg file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +==============================================================================*/ + +#include +#include +#include +#include +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) \ + && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +# include +#endif +#include +#include +#include +#include + +#include "fixture.hpp" + +template