diff options
Diffstat (limited to 'src/boost/libs/fusion/test/support')
-rw-r--r-- | src/boost/libs/fusion/test/support/and.cpp | 28 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/index_sequence.cpp | 32 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/is_sequence.cpp | 17 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/is_view.cpp | 15 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/pair_container.hpp | 27 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/pair_deque.cpp | 17 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/pair_list.cpp | 17 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/pair_map.cpp | 17 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/pair_nest.cpp | 24 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/pair_set.cpp | 17 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/pair_vector.cpp | 17 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/tag_of.cpp | 17 | ||||
-rw-r--r-- | src/boost/libs/fusion/test/support/unused.cpp | 96 |
13 files changed, 341 insertions, 0 deletions
diff --git a/src/boost/libs/fusion/test/support/and.cpp b/src/boost/libs/fusion/test/support/and.cpp new file mode 100644 index 00000000..604a68d7 --- /dev/null +++ b/src/boost/libs/fusion/test/support/and.cpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2016 Lee Clagett + Copyright (c) 2018 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 <boost/config.hpp> + +#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES +# error "does not meet requirements" +#endif + +#include <boost/fusion/support/detail/and.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/assert.hpp> + +using namespace boost; +using namespace boost::fusion::detail; + +BOOST_MPL_ASSERT((and_<>)); +BOOST_MPL_ASSERT_NOT((and_<false_type>)); +BOOST_MPL_ASSERT((and_<true_type>)); +BOOST_MPL_ASSERT_NOT((and_<true_type, false_type>)); +BOOST_MPL_ASSERT((and_<true_type, true_type>)); +BOOST_MPL_ASSERT_NOT((and_<true_type, true_type, false_type>)); +BOOST_MPL_ASSERT((and_<true_type, true_type, true_type>)); +BOOST_MPL_ASSERT((and_<true_type, mpl::true_>)); diff --git a/src/boost/libs/fusion/test/support/index_sequence.cpp b/src/boost/libs/fusion/test/support/index_sequence.cpp new file mode 100644 index 00000000..019ae474 --- /dev/null +++ b/src/boost/libs/fusion/test/support/index_sequence.cpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2015,2018 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 <boost/config.hpp> + +#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES +# error "does not meet requirements" +#endif + +#include <boost/fusion/support/detail/index_sequence.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_same.hpp> + +using namespace boost::fusion; + +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<0>::type, detail::index_sequence<> >)); +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<1>::type, detail::index_sequence<0> >)); +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<2>::type, detail::index_sequence<0, 1> >)); +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<3>::type, detail::index_sequence<0, 1, 2> >)); +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<4>::type, detail::index_sequence<0, 1, 2, 3> >)); +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<5>::type, detail::index_sequence<0, 1, 2, 3, 4> >)); +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<6>::type, detail::index_sequence<0, 1, 2, 3, 4, 5> >)); +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<7>::type, detail::index_sequence<0, 1, 2, 3, 4, 5, 6> >)); +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<8>::type, detail::index_sequence<0, 1, 2, 3, 4, 5, 6, 7> >)); + +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<15>::type, detail::index_sequence<0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14> >)); +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<16>::type, detail::index_sequence<0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15> >)); +BOOST_MPL_ASSERT((boost::is_same<detail::make_index_sequence<17>::type, detail::index_sequence<0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16> >)); + diff --git a/src/boost/libs/fusion/test/support/is_sequence.cpp b/src/boost/libs/fusion/test/support/is_sequence.cpp new file mode 100644 index 00000000..428f6354 --- /dev/null +++ b/src/boost/libs/fusion/test/support/is_sequence.cpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2018 Louis Dionne + + 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 <boost/fusion/support/is_sequence.hpp> +#include <boost/static_assert.hpp> + + +// Make sure fusion::is_sequence and fusion::is_native_fusion_sequence can be +// used with an incomplete type. +struct incomplete; +BOOST_STATIC_ASSERT(!boost::fusion::traits::is_sequence<incomplete>::value); +BOOST_STATIC_ASSERT(!boost::fusion::traits::is_native_fusion_sequence<incomplete>::value); + +int main() { } diff --git a/src/boost/libs/fusion/test/support/is_view.cpp b/src/boost/libs/fusion/test/support/is_view.cpp new file mode 100644 index 00000000..068f1a80 --- /dev/null +++ b/src/boost/libs/fusion/test/support/is_view.cpp @@ -0,0 +1,15 @@ +/*============================================================================= + Copyright (c) 2018 Nikita Kniazev + + 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 <boost/fusion/support/is_view.hpp> +#include <boost/static_assert.hpp> + + +// Make sure fusion::is_view can be used with non fusion types. +struct incomplete; +BOOST_STATIC_ASSERT(!boost::fusion::traits::is_view<incomplete>::value); + +int main() { } diff --git a/src/boost/libs/fusion/test/support/pair_container.hpp b/src/boost/libs/fusion/test/support/pair_container.hpp new file mode 100644 index 00000000..3e84f058 --- /dev/null +++ b/src/boost/libs/fusion/test/support/pair_container.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2014 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 <boost/core/ignore_unused.hpp> +#include <boost/fusion/support/pair.hpp> + +using namespace boost::fusion; + +template <typename C> +void copy() +{ + pair<int, C> src; + pair<int, C> dest = src; + boost::ignore_unused(dest); +} + +void test() +{ + copy<FUSION_SEQUENCE<> >(); + copy<FUSION_SEQUENCE<TEST_TYPE> >(); + copy<FUSION_SEQUENCE<TEST_TYPE, TEST_TYPE> >(); +} + diff --git a/src/boost/libs/fusion/test/support/pair_deque.cpp b/src/boost/libs/fusion/test/support/pair_deque.cpp new file mode 100644 index 00000000..27da30ec --- /dev/null +++ b/src/boost/libs/fusion/test/support/pair_deque.cpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2014 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 <boost/fusion/container/deque/deque.hpp> + +#define FUSION_SEQUENCE deque +#define TEST_TYPE int +#include "./pair_container.hpp" + +int main() +{ + test(); +} + diff --git a/src/boost/libs/fusion/test/support/pair_list.cpp b/src/boost/libs/fusion/test/support/pair_list.cpp new file mode 100644 index 00000000..ce478ff6 --- /dev/null +++ b/src/boost/libs/fusion/test/support/pair_list.cpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2014 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 <boost/fusion/container/list/list.hpp> + +#define FUSION_SEQUENCE list +#define TEST_TYPE int +#include "./pair_container.hpp" + +int main() +{ + test(); +} + diff --git a/src/boost/libs/fusion/test/support/pair_map.cpp b/src/boost/libs/fusion/test/support/pair_map.cpp new file mode 100644 index 00000000..d472ba26 --- /dev/null +++ b/src/boost/libs/fusion/test/support/pair_map.cpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2014 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 <boost/fusion/container/map/map.hpp> + +#define FUSION_SEQUENCE map +#define TEST_TYPE pair<int,int> +#include "./pair_container.hpp" + +int main() +{ + test(); +} + diff --git a/src/boost/libs/fusion/test/support/pair_nest.cpp b/src/boost/libs/fusion/test/support/pair_nest.cpp new file mode 100644 index 00000000..fbc253cb --- /dev/null +++ b/src/boost/libs/fusion/test/support/pair_nest.cpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 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) +==============================================================================*/ +#include <boost/core/ignore_unused.hpp> +#include <boost/fusion/support/pair.hpp> + +using namespace boost::fusion; + +template <typename C> +void copy() +{ + pair<int, C> src; + pair<int, C> dest = src; + boost::ignore_unused(dest); +} + +int main() +{ + copy<pair<void, float> >(); +} + diff --git a/src/boost/libs/fusion/test/support/pair_set.cpp b/src/boost/libs/fusion/test/support/pair_set.cpp new file mode 100644 index 00000000..b346a8ba --- /dev/null +++ b/src/boost/libs/fusion/test/support/pair_set.cpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2014 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 <boost/fusion/container/set/set.hpp> + +#define FUSION_SEQUENCE set +#define TEST_TYPE int +#include "./pair_container.hpp" + +int main() +{ + test(); +} + diff --git a/src/boost/libs/fusion/test/support/pair_vector.cpp b/src/boost/libs/fusion/test/support/pair_vector.cpp new file mode 100644 index 00000000..62a4f2b5 --- /dev/null +++ b/src/boost/libs/fusion/test/support/pair_vector.cpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2014 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 <boost/fusion/container/vector/vector.hpp> + +#define FUSION_SEQUENCE vector +#define TEST_TYPE int +#include "./pair_container.hpp" + +int main() +{ + test(); +} + diff --git a/src/boost/libs/fusion/test/support/tag_of.cpp b/src/boost/libs/fusion/test/support/tag_of.cpp new file mode 100644 index 00000000..ee2da10d --- /dev/null +++ b/src/boost/libs/fusion/test/support/tag_of.cpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2018 Louis Dionne + + 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 <boost/fusion/support/tag_of.hpp> +#include <boost/static_assert.hpp> +#include <boost/type_traits/is_same.hpp> + + +// Make sure tag_of can be used with an incomplete type. +struct incomplete; +typedef boost::fusion::traits::tag_of<incomplete>::type Tag; +BOOST_STATIC_ASSERT((boost::is_same<Tag, boost::fusion::non_fusion_tag>::value)); + +int main() { } diff --git a/src/boost/libs/fusion/test/support/unused.cpp b/src/boost/libs/fusion/test/support/unused.cpp new file mode 100644 index 00000000..8b9e6260 --- /dev/null +++ b/src/boost/libs/fusion/test/support/unused.cpp @@ -0,0 +1,96 @@ +/*============================================================================= + Copyright (c) 2018 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 <boost/config.hpp> +#include <boost/fusion/support/unused.hpp> +#include <boost/type_traits/detail/yes_no_type.hpp> +#include <boost/static_assert.hpp> +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +#include <utility> +#endif + +struct T { }; + +void unused_construction() +{ + boost::fusion::unused_type dephault; + + boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED parenthesis = boost::fusion::unused_type(); +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED brace{}; + boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED list_copy = {}; +#endif + + boost::fusion::unused_type copy_copy BOOST_ATTRIBUTE_UNUSED = dephault; + boost::fusion::unused_type copy_direct BOOST_ATTRIBUTE_UNUSED (dephault); +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + boost::fusion::unused_type copy_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {dephault}; + boost::fusion::unused_type copy_direct_brace BOOST_ATTRIBUTE_UNUSED {dephault}; +#endif + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + boost::fusion::unused_type move_copy BOOST_ATTRIBUTE_UNUSED = std::move(dephault); + boost::fusion::unused_type move_direct BOOST_ATTRIBUTE_UNUSED (std::move(dephault)); +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + boost::fusion::unused_type move_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {std::move(dephault)}; + boost::fusion::unused_type move_direct_brace BOOST_ATTRIBUTE_UNUSED {std::move(dephault)}; +#endif +#endif + + + T value; + + boost::fusion::unused_type T_copy_copy BOOST_ATTRIBUTE_UNUSED = value; + boost::fusion::unused_type T_copy_direct BOOST_ATTRIBUTE_UNUSED (value); +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + boost::fusion::unused_type T_copy_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {value}; + boost::fusion::unused_type T_copy_direct_brace BOOST_ATTRIBUTE_UNUSED {value}; +#endif + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + boost::fusion::unused_type T_move_copy BOOST_ATTRIBUTE_UNUSED = std::move(value); + boost::fusion::unused_type T_move_direct BOOST_ATTRIBUTE_UNUSED (std::move(value)); +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + boost::fusion::unused_type T_move_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {std::move(value)}; + boost::fusion::unused_type T_move_direct_brace BOOST_ATTRIBUTE_UNUSED {std::move(value)}; +#endif +#endif +} + +void unused_assignment() +{ + boost::fusion::unused_type val1, val2; + + val1 = val2; +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + val1 = {}; +#endif +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + val1 = std::move(val2); +#endif + + + T value; + + val1 = value; +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + val1 = std::move(value); +#endif +} + +boost::type_traits::yes_type test_unused(boost::fusion::detail::unused_only const&); +boost::type_traits::no_type test_unused(...); + +void only_unused() +{ + BOOST_STATIC_ASSERT((sizeof(test_unused(boost::fusion::unused)) == sizeof(boost::type_traits::yes_type))); + BOOST_STATIC_ASSERT((sizeof(test_unused(0)) == sizeof(boost::type_traits::no_type))); + + boost::fusion::unused_type my_unused; + (void)my_unused; + BOOST_STATIC_ASSERT((sizeof(test_unused(my_unused)) == sizeof(boost::type_traits::yes_type))); +} |