From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- .../libs/hana/test/tuple/any_of.clang_ice.cpp | 19 +++ .../libs/hana/test/tuple/assign.convert_copy.cpp | 59 +++++++++ .../libs/hana/test/tuple/assign.convert_move.cpp | 73 +++++++++++ src/boost/libs/hana/test/tuple/assign.copy.cpp | 43 +++++++ src/boost/libs/hana/test/tuple/assign.move.cpp | 58 +++++++++ src/boost/libs/hana/test/tuple/at.const.cpp | 50 ++++++++ src/boost/libs/hana/test/tuple/at.non_const.cpp | 81 ++++++++++++ src/boost/libs/hana/test/tuple/at.rv.cpp | 40 ++++++ src/boost/libs/hana/test/tuple/auto/_specs.hpp | 15 +++ src/boost/libs/hana/test/tuple/auto/all_of.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/any_of.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/ap.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/at.cpp | 8 ++ .../hana/test/tuple/auto/cartesian_product.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/drop_back.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/drop_front.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/drop_while.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/for_each.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/group.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/index_if.cpp | 9 ++ src/boost/libs/hana/test/tuple/auto/insert.cpp | 8 ++ .../libs/hana/test/tuple/auto/insert_range.cpp | 8 ++ .../libs/hana/test/tuple/auto/intersperse.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/is_empty.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/length.cpp | 8 ++ .../test/tuple/auto/lexicographical_compare.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/make.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/none_of.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/partition.cpp | 8 ++ .../libs/hana/test/tuple/auto/permutations.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/remove_at.cpp | 8 ++ .../libs/hana/test/tuple/auto/remove_range.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/reverse.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/scans.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/sequence.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/slice.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/sort.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/span.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/take_back.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/take_front.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/take_while.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/transform.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/unfolds.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/unique.cpp | 8 ++ src/boost/libs/hana/test/tuple/auto/zips.cpp | 8 ++ .../libs/hana/test/tuple/cnstr.convert_copy.cpp | 93 ++++++++++++++ .../libs/hana/test/tuple/cnstr.convert_move.cpp | 68 ++++++++++ src/boost/libs/hana/test/tuple/cnstr.copy.cpp | 68 ++++++++++ src/boost/libs/hana/test/tuple/cnstr.default.cpp | 138 +++++++++++++++++++++ src/boost/libs/hana/test/tuple/cnstr.move.cpp | 73 +++++++++++ src/boost/libs/hana/test/tuple/cnstr.nested.cpp | 19 +++ src/boost/libs/hana/test/tuple/cnstr.trap.cpp | 120 ++++++++++++++++++ .../libs/hana/test/tuple/cnstr.variadic_array.cpp | 19 +++ .../libs/hana/test/tuple/cnstr.variadic_copy.cpp | 125 +++++++++++++++++++ .../hana/test/tuple/cnstr.variadic_forward.cpp | 114 +++++++++++++++++ src/boost/libs/hana/test/tuple/empty_member.cpp | 33 +++++ src/boost/libs/hana/test/tuple/hold_refs.cpp | 78 ++++++++++++ src/boost/libs/hana/test/tuple/issue_90.cpp | 72 +++++++++++ src/boost/libs/hana/test/tuple/laws.cpp | 43 +++++++ src/boost/libs/hana/test/tuple/laws.functor.cpp | 64 ++++++++++ src/boost/libs/hana/test/tuple/laws.searchable.cpp | 40 ++++++ src/boost/libs/hana/test/tuple/move_only.cpp | 55 ++++++++ src/boost/libs/hana/test/tuple/pair_interop.cpp | 75 +++++++++++ src/boost/libs/hana/test/tuple/smart_ptr.cpp | 23 ++++ .../hana/test/tuple/special.drop_front_exactly.cpp | 46 +++++++ src/boost/libs/hana/test/tuple/special.empty.cpp | 25 ++++ src/boost/libs/hana/test/tuple/special.equal.cpp | 76 ++++++++++++ src/boost/libs/hana/test/tuple/special.fill.cpp | 36 ++++++ .../libs/hana/test/tuple/special.fold_left.cpp | 68 ++++++++++ .../libs/hana/test/tuple/special.fold_right.cpp | 68 ++++++++++ src/boost/libs/hana/test/tuple/special.front.cpp | 46 +++++++ .../libs/hana/test/tuple/special.is_empty.cpp | 28 +++++ src/boost/libs/hana/test/tuple/special.prepend.cpp | 30 +++++ .../libs/hana/test/tuple/special.transform.cpp | 52 ++++++++ src/boost/libs/hana/test/tuple/to.cpp | 18 +++ src/boost/libs/hana/test/tuple/unpack.cpp | 89 +++++++++++++ .../libs/hana/test/tuple/usability_of_types.cpp | 41 ++++++ 77 files changed, 2670 insertions(+) create mode 100644 src/boost/libs/hana/test/tuple/any_of.clang_ice.cpp create mode 100644 src/boost/libs/hana/test/tuple/assign.convert_copy.cpp create mode 100644 src/boost/libs/hana/test/tuple/assign.convert_move.cpp create mode 100644 src/boost/libs/hana/test/tuple/assign.copy.cpp create mode 100644 src/boost/libs/hana/test/tuple/assign.move.cpp create mode 100644 src/boost/libs/hana/test/tuple/at.const.cpp create mode 100644 src/boost/libs/hana/test/tuple/at.non_const.cpp create mode 100644 src/boost/libs/hana/test/tuple/at.rv.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/_specs.hpp create mode 100644 src/boost/libs/hana/test/tuple/auto/all_of.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/any_of.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/ap.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/at.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/cartesian_product.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/drop_back.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/drop_front.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/drop_while.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/for_each.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/group.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/index_if.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/insert.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/insert_range.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/intersperse.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/is_empty.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/length.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/lexicographical_compare.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/make.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/none_of.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/partition.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/permutations.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/remove_at.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/remove_range.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/reverse.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/scans.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/sequence.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/slice.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/sort.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/span.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/take_back.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/take_front.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/take_while.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/transform.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/unfolds.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/unique.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/zips.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.convert_copy.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.convert_move.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.copy.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.default.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.move.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.nested.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.trap.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.variadic_array.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.variadic_copy.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.variadic_forward.cpp create mode 100644 src/boost/libs/hana/test/tuple/empty_member.cpp create mode 100644 src/boost/libs/hana/test/tuple/hold_refs.cpp create mode 100644 src/boost/libs/hana/test/tuple/issue_90.cpp create mode 100644 src/boost/libs/hana/test/tuple/laws.cpp create mode 100644 src/boost/libs/hana/test/tuple/laws.functor.cpp create mode 100644 src/boost/libs/hana/test/tuple/laws.searchable.cpp create mode 100644 src/boost/libs/hana/test/tuple/move_only.cpp create mode 100644 src/boost/libs/hana/test/tuple/pair_interop.cpp create mode 100644 src/boost/libs/hana/test/tuple/smart_ptr.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.drop_front_exactly.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.empty.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.equal.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.fill.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.fold_left.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.fold_right.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.front.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.is_empty.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.prepend.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.transform.cpp create mode 100644 src/boost/libs/hana/test/tuple/to.cpp create mode 100644 src/boost/libs/hana/test/tuple/unpack.cpp create mode 100644 src/boost/libs/hana/test/tuple/usability_of_types.cpp (limited to 'src/boost/libs/hana/test/tuple') diff --git a/src/boost/libs/hana/test/tuple/any_of.clang_ice.cpp b/src/boost/libs/hana/test/tuple/any_of.clang_ice.cpp new file mode 100644 index 000000000..4e23874c0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/any_of.clang_ice.cpp @@ -0,0 +1,19 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +namespace hana = boost::hana; + + +// This used to trigger an ICE on Clang + +struct Car { std::string name; }; + +int main() { + auto stuff = hana::make_tuple(Car{}, Car{}, Car{}); + hana::any_of(stuff, [](auto&&) { return true; }); +} diff --git a/src/boost/libs/hana/test/tuple/assign.convert_copy.cpp b/src/boost/libs/hana/test/tuple/assign.convert_copy.cpp new file mode 100644 index 000000000..b4debb7a6 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/assign.convert_copy.cpp @@ -0,0 +1,59 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +namespace hana = boost::hana; + + +struct B { + int id_; + explicit B(int i = 0) : id_(i) { } +}; + +struct D : B { + explicit D(int i = 0) : B(i) { } +}; + +int main() { + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5); + T1 t1; + t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a'); + T1 t1; + t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', D(3)); + T1 t1; + t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3); + } + { + D d(3); + D d2(2); + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', d2); + T1 t1(1.5, 'b', d); + t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2); + } +} diff --git a/src/boost/libs/hana/test/tuple/assign.convert_move.cpp b/src/boost/libs/hana/test/tuple/assign.convert_move.cpp new file mode 100644 index 000000000..6a7a7943e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/assign.convert_move.cpp @@ -0,0 +1,73 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +#include +namespace hana = boost::hana; + + +struct B { + int id_; + explicit B(int i = 0) : id_(i) {} + virtual ~B() {} +}; + +struct D : B { + explicit D(int i) : B(i) {} +}; + +int main() { + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5); + T1 t1; + t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a'); + T1 t1; + t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', D(3)); + T1 t1; + t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3); + } + { + D d(3); + D d2(2); + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', d2); + T1 t1(1.5, 'b', d); + t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2); + } + { + using T0 = hana::tuple>; + using T1 = hana::tuple>; + T0 t0(2.5, 'a', std::unique_ptr(new D(3))); + T1 t1; + t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1)->id_ == 3); + } +} diff --git a/src/boost/libs/hana/test/tuple/assign.copy.cpp b/src/boost/libs/hana/test/tuple/assign.copy.cpp new file mode 100644 index 000000000..dedc276a5 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/assign.copy.cpp @@ -0,0 +1,43 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + { + using T = hana::tuple<>; + T t0; + T t; + t = t0; + } + { + using T = hana::tuple; + T t0(2); + T t; + t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + } + { + using T = hana::tuple; + T t0(2, 'a'); + T t; + t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); + } + { + using T = hana::tuple; + const T t0(2, 'a', "some text"); + T t; + t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == "some text"); + } +} diff --git a/src/boost/libs/hana/test/tuple/assign.move.cpp b/src/boost/libs/hana/test/tuple/assign.move.cpp new file mode 100644 index 000000000..6dd776129 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/assign.move.cpp @@ -0,0 +1,58 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +namespace hana = boost::hana; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data = 1) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + int get() const {return data_;} + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } + bool operator< (const MoveOnly& x) const { return data_ < x.data_; } +}; + +int main() { + { + using T = hana::tuple<>; + T t0; + T t; + t = std::move(t0); + } + { + using T = hana::tuple; + T t0(MoveOnly(0)); + T t; + t = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + } + { + using T = hana::tuple; + T t0(MoveOnly(0), MoveOnly(1)); + T t; + t = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + } + { + using T = hana::tuple; + T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2)); + T t; + t = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2); + } +} diff --git a/src/boost/libs/hana/test/tuple/at.const.cpp b/src/boost/libs/hana/test/tuple/at.const.cpp new file mode 100644 index 000000000..47d9b624c --- /dev/null +++ b/src/boost/libs/hana/test/tuple/at.const.cpp @@ -0,0 +1,50 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +namespace hana = boost::hana; + + +struct Empty { }; + +int main() { + { + using T = hana::tuple; + const T t(3); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 3); + } + { + using T = hana::tuple; + const T t("high", 5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == "high"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 5); + } + { + using T = hana::tuple; + constexpr T t(2.718, 5); + static_assert(hana::at_c<0>(t) == 2.718, ""); + static_assert(hana::at_c<1>(t) == 5, ""); + } + { + using T = hana::tuple; + constexpr T t{Empty()}; + constexpr Empty e = hana::at_c<0>(t); (void)e; + } + { + using T = hana::tuple; + double d = 1.5; + const T t(d, "high", 5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1.5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "high"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 5); + hana::at_c<0>(t) = 2.5; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2.5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "high"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 5); + BOOST_HANA_RUNTIME_CHECK(d == 2.5); + } +} diff --git a/src/boost/libs/hana/test/tuple/at.non_const.cpp b/src/boost/libs/hana/test/tuple/at.non_const.cpp new file mode 100644 index 000000000..3e47c35d9 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/at.non_const.cpp @@ -0,0 +1,81 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +namespace hana = boost::hana; + + +struct Empty {}; + +struct S { + constexpr S() + : a{1, Empty{}}, + k(hana::at_c<0>(a)), + e(hana::at_c<1>(a)) + { } + + hana::tuple a; + int k; + Empty e; +}; + +constexpr hana::tuple getP () { return { 3, 4 }; } + +int main() { + { + using T = hana::tuple; + T t(3); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 3); + hana::at_c<0>(t) = 2; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + } + { + using T = hana::tuple; + T t("high", 5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == "high"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 5); + hana::at_c<0>(t) = "four"; + hana::at_c<1>(t) = 4; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == "four"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 4); + } + { + using T = hana::tuple; + double d = 1.5; + T t(d, "high", 5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1.5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "high"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 5); + hana::at_c<0>(t) = 2.5; + hana::at_c<1>(t) = "four"; + hana::at_c<2>(t) = 4; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2.5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "four"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 4); + BOOST_HANA_RUNTIME_CHECK(d == 2.5); + } + // get on a rvalue tuple + { + static_assert(hana::at_c<0>(hana::tuple{0.0f, 1, 2.0, 3L}) == 0, "" ); + static_assert(hana::at_c<1>(hana::tuple{0.0f, 1, 2.0, 3L}) == 1, "" ); + static_assert(hana::at_c<2>(hana::tuple{0.0f, 1, 2.0, 3L}) == 2, "" ); + static_assert(hana::at_c<3>(hana::tuple{0.0f, 1, 2.0, 3L}) == 3, "" ); + static_assert(S().k == 1, ""); + static_assert(hana::at_c<1>(getP()) == 4, ""); + } + { + // make sure get<> returns the right types + struct T { }; + struct U { }; + struct V { }; + + hana::tuple xs{}; + (void)static_cast(hana::at_c<0>(xs)); + (void)static_cast(hana::at_c<1>(xs)); + (void)static_cast(hana::at_c<2>(xs)); + } +} diff --git a/src/boost/libs/hana/test/tuple/at.rv.cpp b/src/boost/libs/hana/test/tuple/at.rv.cpp new file mode 100644 index 000000000..e1591609b --- /dev/null +++ b/src/boost/libs/hana/test/tuple/at.rv.cpp @@ -0,0 +1,40 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include + +#include +#include +namespace hana = boost::hana; + + +int main() { + { + using T = hana::tuple>; + T t(std::unique_ptr(new int(3))); + std::unique_ptr p = hana::at_c<0>(std::move(t)); + BOOST_HANA_RUNTIME_CHECK(*p == 3); + } + // make sure we don't double-move and do other weird stuff + { + hana::tuple xs{ + Tracked{1}, Tracked{2}, Tracked{3} + }; + + Tracked a = hana::at_c<0>(std::move(xs)); (void)a; + Tracked b = hana::at_c<1>(std::move(xs)); (void)b; + Tracked c = hana::at_c<2>(std::move(xs)); (void)c; + } + // test with nested closures + { + using Inner = hana::tuple; + hana::tuple xs{Inner{Tracked{1}, Tracked{2}}}; + + Tracked a = hana::at_c<0>(hana::at_c<0>(std::move(xs))); (void)a; + Tracked b = hana::at_c<1>(hana::at_c<0>(std::move(xs))); (void)b; + } +} diff --git a/src/boost/libs/hana/test/tuple/auto/_specs.hpp b/src/boost/libs/hana/test/tuple/auto/_specs.hpp new file mode 100644 index 000000000..0b957f4c8 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/_specs.hpp @@ -0,0 +1,15 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_TUPLE_AUTO_SPECS_HPP +#define BOOST_HANA_TEST_TUPLE_AUTO_SPECS_HPP + +#include + + +#define MAKE_TUPLE(...) ::boost::hana::make_tuple(__VA_ARGS__) +#define TUPLE_TYPE(...) ::boost::hana::tuple<__VA_ARGS__> +#define TUPLE_TAG ::boost::hana::tuple_tag + +#endif // !BOOST_HANA_TEST_TUPLE_AUTO_SPECS_HPP diff --git a/src/boost/libs/hana/test/tuple/auto/all_of.cpp b/src/boost/libs/hana/test/tuple/auto/all_of.cpp new file mode 100644 index 000000000..f3e974ffd --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/all_of.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/any_of.cpp b/src/boost/libs/hana/test/tuple/auto/any_of.cpp new file mode 100644 index 000000000..3065d0175 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/any_of.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/ap.cpp b/src/boost/libs/hana/test/tuple/auto/ap.cpp new file mode 100644 index 000000000..59c9cb757 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/ap.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/at.cpp b/src/boost/libs/hana/test/tuple/auto/at.cpp new file mode 100644 index 000000000..605265331 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/at.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/cartesian_product.cpp b/src/boost/libs/hana/test/tuple/auto/cartesian_product.cpp new file mode 100644 index 000000000..b0795e8d7 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/cartesian_product.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/drop_back.cpp b/src/boost/libs/hana/test/tuple/auto/drop_back.cpp new file mode 100644 index 000000000..b283844d6 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/drop_back.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/drop_front.cpp b/src/boost/libs/hana/test/tuple/auto/drop_front.cpp new file mode 100644 index 000000000..a39d6f450 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/drop_front.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/drop_while.cpp b/src/boost/libs/hana/test/tuple/auto/drop_while.cpp new file mode 100644 index 000000000..18907f033 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/drop_while.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/for_each.cpp b/src/boost/libs/hana/test/tuple/auto/for_each.cpp new file mode 100644 index 000000000..714fe03c0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/for_each.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/group.cpp b/src/boost/libs/hana/test/tuple/auto/group.cpp new file mode 100644 index 000000000..0669b496f --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/group.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/index_if.cpp b/src/boost/libs/hana/test/tuple/auto/index_if.cpp new file mode 100644 index 000000000..ef37fe65a --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/index_if.cpp @@ -0,0 +1,9 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/insert.cpp b/src/boost/libs/hana/test/tuple/auto/insert.cpp new file mode 100644 index 000000000..e8efc6dc1 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/insert.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/insert_range.cpp b/src/boost/libs/hana/test/tuple/auto/insert_range.cpp new file mode 100644 index 000000000..05ac5774e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/insert_range.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/intersperse.cpp b/src/boost/libs/hana/test/tuple/auto/intersperse.cpp new file mode 100644 index 000000000..185c814a9 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/intersperse.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/is_empty.cpp b/src/boost/libs/hana/test/tuple/auto/is_empty.cpp new file mode 100644 index 000000000..f175f7ddb --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/is_empty.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/length.cpp b/src/boost/libs/hana/test/tuple/auto/length.cpp new file mode 100644 index 000000000..55111dd60 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/length.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/lexicographical_compare.cpp b/src/boost/libs/hana/test/tuple/auto/lexicographical_compare.cpp new file mode 100644 index 000000000..4d2f3edf4 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/lexicographical_compare.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/make.cpp b/src/boost/libs/hana/test/tuple/auto/make.cpp new file mode 100644 index 000000000..f90514f16 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/make.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/none_of.cpp b/src/boost/libs/hana/test/tuple/auto/none_of.cpp new file mode 100644 index 000000000..b56a27b47 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/none_of.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/partition.cpp b/src/boost/libs/hana/test/tuple/auto/partition.cpp new file mode 100644 index 000000000..ba9621a6c --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/partition.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/permutations.cpp b/src/boost/libs/hana/test/tuple/auto/permutations.cpp new file mode 100644 index 000000000..3c1a6e852 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/permutations.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/remove_at.cpp b/src/boost/libs/hana/test/tuple/auto/remove_at.cpp new file mode 100644 index 000000000..5b7c5af47 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/remove_at.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/remove_range.cpp b/src/boost/libs/hana/test/tuple/auto/remove_range.cpp new file mode 100644 index 000000000..6d7c6e090 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/remove_range.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/reverse.cpp b/src/boost/libs/hana/test/tuple/auto/reverse.cpp new file mode 100644 index 000000000..342278df8 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/reverse.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/scans.cpp b/src/boost/libs/hana/test/tuple/auto/scans.cpp new file mode 100644 index 000000000..36dd32437 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/scans.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/sequence.cpp b/src/boost/libs/hana/test/tuple/auto/sequence.cpp new file mode 100644 index 000000000..4ed01e852 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/sequence.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/slice.cpp b/src/boost/libs/hana/test/tuple/auto/slice.cpp new file mode 100644 index 000000000..3e20df95f --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/slice.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/sort.cpp b/src/boost/libs/hana/test/tuple/auto/sort.cpp new file mode 100644 index 000000000..f639ddeb0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/sort.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/span.cpp b/src/boost/libs/hana/test/tuple/auto/span.cpp new file mode 100644 index 000000000..297b7f174 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/span.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/take_back.cpp b/src/boost/libs/hana/test/tuple/auto/take_back.cpp new file mode 100644 index 000000000..2a91d7d4d --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/take_back.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/take_front.cpp b/src/boost/libs/hana/test/tuple/auto/take_front.cpp new file mode 100644 index 000000000..9a48d2b8c --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/take_front.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/take_while.cpp b/src/boost/libs/hana/test/tuple/auto/take_while.cpp new file mode 100644 index 000000000..e58c99aca --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/take_while.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/transform.cpp b/src/boost/libs/hana/test/tuple/auto/transform.cpp new file mode 100644 index 000000000..306c1bc3c --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/transform.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/unfolds.cpp b/src/boost/libs/hana/test/tuple/auto/unfolds.cpp new file mode 100644 index 000000000..f8bac9ddc --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/unfolds.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/unique.cpp b/src/boost/libs/hana/test/tuple/auto/unique.cpp new file mode 100644 index 000000000..9c1dc7155 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/unique.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/zips.cpp b/src/boost/libs/hana/test/tuple/auto/zips.cpp new file mode 100644 index 000000000..32ec5cc8a --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/zips.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/cnstr.convert_copy.cpp b/src/boost/libs/hana/test/tuple/cnstr.convert_copy.cpp new file mode 100644 index 000000000..f8cb0d8de --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.convert_copy.cpp @@ -0,0 +1,93 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +namespace hana = boost::hana; + + +struct A { + int id_; + constexpr A(int i) : id_(i) {} + friend constexpr bool operator==(const A& x, const A& y) + { return x.id_ == y.id_; } +}; + +struct B { + int id_; + explicit B(int i) : id_(i) {} +}; + +struct C { + int id_; + constexpr explicit C(int i) : id_(i) {} + friend constexpr bool operator==(const C& x, const C& y) + { return x.id_ == y.id_; } +}; + +struct D : B { + explicit D(int i) : B(i) {} +}; + + +int main() { + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5); + T1 t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + constexpr T0 t0(2.5); + constexpr T1 t1 = t0; + static_assert(hana::at_c<0>(t1) == 2, ""); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + constexpr T0 t0(2); + constexpr T1 t1{t0}; + static_assert(hana::at_c<0>(t1) == C(2), ""); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a'); + T1 t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', D(3)); + T1 t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3); + } + { + D d(3); + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', d); + T1 t1 = t0; + d.id_ = 2; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', 3); + T1 t1(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3); + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.convert_move.cpp b/src/boost/libs/hana/test/tuple/cnstr.convert_move.cpp new file mode 100644 index 000000000..f8274429e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.convert_move.cpp @@ -0,0 +1,68 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +#include +namespace hana = boost::hana; + + +struct B { + int id_; + explicit B(int i) : id_(i) {} + virtual ~B() {} +}; + +struct D : B { + explicit D(int i) : B(i) {} +}; + +int main() { + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5); + T1 t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a'); + T1 t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', D(3)); + T1 t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3); + } + { + D d(3); + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', d); + T1 t1 = std::move(t0); + d.id_ = 2; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2); + } + { + using T0 = hana::tuple>; + using T1 = hana::tuple>; + T0 t0(2.5, 'a', std::unique_ptr(new D(3))); + T1 t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1)->id_ == 3); + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.copy.cpp b/src/boost/libs/hana/test/tuple/cnstr.copy.cpp new file mode 100644 index 000000000..e0d8638f0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.copy.cpp @@ -0,0 +1,68 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +namespace hana = boost::hana; + + +struct Empty { }; + +int main() { + { + using T = hana::tuple<>; + T t0; + T t_implicit = t0; + T t_explicit(t0); + + (void)t_explicit; + (void)t_implicit; + } + { + using T = hana::tuple; + T t0(2); + T t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + } + { + using T = hana::tuple; + T t0(2, 'a'); + T t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); + } + { + using T = hana::tuple; + const T t0(2, 'a', "some text"); + T t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == "some text"); + } + { + using T = hana::tuple; + constexpr T t0(2); + constexpr T t = t0; + static_assert(hana::at_c<0>(t) == 2, ""); + } + { + using T = hana::tuple; + constexpr T t0; + constexpr T t = t0; + constexpr Empty e = hana::at_c<0>(t); (void)e; + } + { + struct T { }; + struct U { }; + + constexpr hana::tuple binary{}; + constexpr hana::tuple copy_implicit = binary; + constexpr hana::tuple copy_explicit(binary); + + (void)copy_implicit; + (void)copy_explicit; + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.default.cpp b/src/boost/libs/hana/test/tuple/cnstr.default.cpp new file mode 100644 index 000000000..5d9af67a2 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.default.cpp @@ -0,0 +1,138 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +#include +namespace hana = boost::hana; + + +struct DefaultOnly { + int data_; + DefaultOnly(DefaultOnly const&) = delete; + DefaultOnly& operator=(DefaultOnly const&) = delete; + + static int count; + + DefaultOnly() : data_(-1) { ++count; } + ~DefaultOnly() { data_ = 0; --count; } + + friend bool operator==(DefaultOnly const& x, DefaultOnly const& y) + { return x.data_ == y.data_; } + + friend bool operator< (DefaultOnly const& x, DefaultOnly const& y) + { return x.data_ < y.data_; } +}; + +int DefaultOnly::count = 0; + +struct NoDefault { + NoDefault() = delete; + explicit NoDefault(int) { } +}; + +struct IllFormedDefault { + IllFormedDefault(int x) : value(x) {} + template + constexpr IllFormedDefault() { + static_assert(Pred, + "The default constructor should not be instantiated"); + } + int value; +}; + +int main() { + { + hana::tuple<> t; (void)t; + } + { + hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + } + { + hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + } + { + hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == ""); + } + { + hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == ""); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(t) == DefaultOnly()); + } + { + // See LLVM bug #21157. + static_assert(!std::is_default_constructible< + hana::tuple + >(), ""); + static_assert(!std::is_default_constructible< + hana::tuple + >(), ""); + static_assert(!std::is_default_constructible< + hana::tuple + >(), ""); + } + { + struct T { }; + struct U { }; + struct V { }; + + constexpr hana::tuple<> z0; (void)z0; + constexpr hana::tuple z1; (void)z1; + constexpr hana::tuple z2; (void)z2; + constexpr hana::tuple z3; (void)z3; + } + { + constexpr hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + } + { + constexpr hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + } + + // Make sure we can hold non default-constructible elements, and that + // it does not trigger an error in the default constructor. + { + { + IllFormedDefault v(0); + hana::tuple t1(v); + hana::tuple t2{v}; + hana::tuple t3 = {v}; + (void)t1;(void)t2;(void)t3; // remove spurious unused variable warning on GCC + } + { + hana::tuple t1(0); + hana::tuple t2{0}; + hana::tuple t3 = {0}; + (void)t1;(void)t2;(void)t3; // remove spurious unused variable warning on GCC + } + { + NoDefault v(0); + hana::tuple t1(v); + hana::tuple t2{v}; + hana::tuple t3 = {v}; + (void)t1;(void)t2;(void)t3; // remove spurious unused variable warning on GCC + } + } + + // Make sure a tuple_t can be default-constructed + { + struct T; + struct U; + + using Types = decltype(hana::tuple_t); + Types t{}; (void)t; + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.move.cpp b/src/boost/libs/hana/test/tuple/cnstr.move.cpp new file mode 100644 index 000000000..c9644cbad --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.move.cpp @@ -0,0 +1,73 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +#include +namespace hana = boost::hana; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data = 1) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + int get() const {return data_;} + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } + bool operator< (const MoveOnly& x) const { return data_ < x.data_; } +}; + +int main() { + { + using T = hana::tuple<>; + T t0; + T t = std::move(t0); (void)t; + } + { + using T = hana::tuple; + T t0(MoveOnly(0)); + T t = std::move(t0); (void)t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + } + { + using T = hana::tuple; + T t0(MoveOnly(0), MoveOnly(1)); + T t = std::move(t0); (void)t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + } + { + using T = hana::tuple; + T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2)); + T t = std::move(t0); (void)t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2); + } + { + // Check for SFINAE-friendliness + static_assert(!std::is_constructible< + hana::tuple, MoveOnly const& + >{}, ""); + + static_assert(!std::is_constructible< + hana::tuple, MoveOnly& + >{}, ""); + + static_assert(std::is_constructible< + hana::tuple, MoveOnly + >{}, ""); + + static_assert(std::is_constructible< + hana::tuple, MoveOnly&& + >{}, ""); + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.nested.cpp b/src/boost/libs/hana/test/tuple/cnstr.nested.cpp new file mode 100644 index 000000000..7cbdb5da6 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.nested.cpp @@ -0,0 +1,19 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +// See this bug: https://llvm.org/bugs/show_bug.cgi?id=24173 + +template +constexpr hana::tuple...> f(Xs&& ...xs) +{ return hana::tuple...>{static_cast(xs)...}; } + +int main() { + f(f(f(f(f(f(f(f(f(f(f(f(1)))))))))))); +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.trap.cpp b/src/boost/libs/hana/test/tuple/cnstr.trap.cpp new file mode 100644 index 000000000..a088b9466 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.trap.cpp @@ -0,0 +1,120 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +// Make sure that the tuple(Yn&&...) is not preferred over copy constructors +// in single-element cases and other similar cases. + +struct Trap1 { + Trap1() = default; + Trap1(Trap1 const&) = default; +#ifndef BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 + Trap1(Trap1&) = default; +#endif + Trap1(Trap1&&) = default; + + template + Trap1(X&&) { + static_assert(sizeof(X) && false, + "this constructor must not be instantiated"); + } +}; + +struct Trap2 { + Trap2() = default; + Trap2(Trap2 const&) = default; +#ifndef BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 + Trap2(Trap2&) = default; +#endif + Trap2(Trap2&&) = default; + + template + Trap2(X) { // not by reference + static_assert(sizeof(X) && false, + "this constructor must not be instantiated"); + } +}; + +struct Trap3 { + Trap3() = default; + Trap3(Trap3 const&) = default; +#ifndef BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 + Trap3(Trap3&) = default; +#endif + Trap3(Trap3&&) = default; + + template + constexpr explicit Trap3(X&&) { // explicit, and constexpr + static_assert(sizeof(X) && false, + "this constructor must not be instantiated"); + } +}; + +struct Trap4 { + Trap4() = default; + template + constexpr explicit Trap4(Args&&) { + static_assert(sizeof(Args) && false, "must never be instantiated"); + } + + Trap4(Trap4 const&) = default; + Trap4(Trap4&&) = default; +}; + +int main() { + { + hana::tuple tuple{}; + hana::tuple implicit_copy = tuple; + hana::tuple explicit_copy(tuple); + hana::tuple implicit_move = std::move(tuple); + hana::tuple explicit_move(std::move(tuple)); + + (void)implicit_copy; + (void)explicit_copy; + (void)implicit_move; + (void)explicit_move; + } + + { + hana::tuple tuple{}; + hana::tuple implicit_copy = tuple; + hana::tuple explicit_copy(tuple); + hana::tuple implicit_move = std::move(tuple); + hana::tuple explicit_move(std::move(tuple)); + + (void)implicit_copy; + (void)explicit_copy; + (void)implicit_move; + (void)explicit_move; + } + + { + hana::tuple tuple{}; + hana::tuple implicit_copy = tuple; + hana::tuple explicit_copy(tuple); + hana::tuple implicit_move = std::move(tuple); + hana::tuple explicit_move(std::move(tuple)); + + (void)implicit_copy; + (void)explicit_copy; + (void)implicit_move; + (void)explicit_move; + } + + // Just defining the structure used to cause a failure, because of the + // explicitly defaulted copy-constructor. + { + struct Foo { + Foo() = default; + Foo(Foo const&) = default; + Foo(Foo&&) = default; + hana::tuple t; + }; + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.variadic_array.cpp b/src/boost/libs/hana/test/tuple/cnstr.variadic_array.cpp new file mode 100644 index 000000000..02338b959 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.variadic_array.cpp @@ -0,0 +1,19 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +// +// This test checks that we can NOT construct a tuple holding array members, +// per the standard. +// + +int main() { + static_assert(!std::is_constructible, int[3]>{}, ""); + static_assert(!std::is_constructible, int[3], float[4]>{}, ""); +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.variadic_copy.cpp b/src/boost/libs/hana/test/tuple/cnstr.variadic_copy.cpp new file mode 100644 index 000000000..44f9f4b8e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.variadic_copy.cpp @@ -0,0 +1,125 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +namespace hana = boost::hana; + + +template +struct never { static constexpr bool value = false; }; + +struct NoValueCtor { + NoValueCtor() : id(++count) {} + NoValueCtor(NoValueCtor const & other) : id(other.id) { ++count; } + + // The constexpr is required to make is_constructible instantiate this + // template. The explicit is needed to test-around a similar bug with + // is_convertible. + template + constexpr explicit NoValueCtor(T) + { static_assert(never::value, "This should not be instantiated"); } + + static int count; + int id; +}; + +int NoValueCtor::count = 0; + + +struct NoValueCtorEmpty { + NoValueCtorEmpty() {} + NoValueCtorEmpty(NoValueCtorEmpty const &) {} + + template + constexpr explicit NoValueCtorEmpty(T) + { static_assert(never::value, "This should not be instantiated"); } +}; + +int main() { + { + hana::tuple t(2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + } + { + constexpr hana::tuple t(2); + static_assert(hana::at_c<0>(t) == 2, ""); + } + { + constexpr hana::tuple t; + static_assert(hana::at_c<0>(t) == 0, ""); + } + { + constexpr hana::tuple t(2, nullptr); + static_assert(hana::at_c<0>(t) == 2, ""); + static_assert(hana::at_c<1>(t) == nullptr, ""); + } + { + hana::tuple t(2, nullptr); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + } + { + hana::tuple t(2, nullptr, "text"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == "text"); + } + { + hana::tuple t(1, NoValueCtor(), 2, 3); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t).id == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(t) == 3); + } + { + hana::tuple t(1, NoValueCtorEmpty(), 2, 3); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(t) == 3); + } + { + struct T { }; + struct U { }; + struct V { }; + + constexpr T t{}; + constexpr U u{}; + constexpr V v{}; + + constexpr hana::tuple x1{t}; (void)x1; + constexpr hana::tuple x2{t, u}; (void)x2; + constexpr hana::tuple x3{t, u, v}; (void)x3; + } + { + struct T { }; + struct U { }; + struct V { }; + + // Check for SFINAE-friendliness + static_assert(!std::is_constructible< + hana::tuple, T + >{}, ""); + + static_assert(!std::is_constructible< + hana::tuple, U, T + >{}, ""); + + static_assert(!std::is_constructible< + hana::tuple, T, U, V + >{}, ""); + } + + // Make sure we can initialize elements with the brace-init syntax. + { + struct Member { }; + struct Element { Member member; }; + + hana::tuple xs{{Member()}, {Member()}}; + hana::tuple ys = {{Member()}, {Member()}}; + (void)xs; (void)ys; + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.variadic_forward.cpp b/src/boost/libs/hana/test/tuple/cnstr.variadic_forward.cpp new file mode 100644 index 000000000..dc69ba738 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.variadic_forward.cpp @@ -0,0 +1,114 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +namespace hana = boost::hana; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data = 1) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + int get() const {return data_;} + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } + bool operator< (const MoveOnly& x) const { return data_ < x.data_; } +}; + +struct Empty { }; +struct A { + int id_; + explicit constexpr A(int i) : id_(i) {} +}; + +struct NoDefault { NoDefault() = delete; }; + +int main() { + { + hana::tuple t(MoveOnly(0)); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + } + { + hana::tuple t(MoveOnly(0), MoveOnly(1)); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + } + { + hana::tuple t( + MoveOnly(0), MoveOnly(1), MoveOnly(2) + ); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2); + } + { + constexpr hana::tuple t0{Empty()}; (void)t0; + } + { + constexpr hana::tuple t(3, 2); + static_assert(hana::at_c<0>(t).id_ == 3, ""); + } + { + typedef hana::tuple Tuple; + + static_assert(!std::is_constructible< + Tuple, + MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + Tuple, + MoveOnly, NoDefault + >::value, ""); + } + { + typedef hana::tuple Tuple; + + static_assert(!std::is_constructible< + Tuple, + MoveOnly, MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + Tuple, + MoveOnly, MoveOnly, NoDefault + >::value, ""); + } + { + typedef hana::tuple Tuple; + typedef hana::tuple NestedTuple; + + static_assert(!std::is_constructible< + NestedTuple, + MoveOnly, MoveOnly, MoveOnly, MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + NestedTuple, + MoveOnly, Tuple, MoveOnly, MoveOnly + >::value, ""); + } + { + typedef hana::tuple Tuple; + typedef hana::tuple NestedTuple; + + static_assert(!std::is_constructible< + NestedTuple, + MoveOnly, MoveOnly, MoveOnly, MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + NestedTuple, + MoveOnly, Tuple, MoveOnly, MoveOnly + >::value, ""); + } +} diff --git a/src/boost/libs/hana/test/tuple/empty_member.cpp b/src/boost/libs/hana/test/tuple/empty_member.cpp new file mode 100644 index 000000000..1bab83185 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/empty_member.cpp @@ -0,0 +1,33 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +namespace hana = boost::hana; + + +struct A { }; +struct B { }; + +int main() { + { + using T = hana::tuple; + static_assert(sizeof(T) == sizeof(int), ""); + } + { + using T = hana::tuple; + static_assert(sizeof(T) == sizeof(int), ""); + } + { + using T = hana::tuple; + static_assert(sizeof(T) == sizeof(int), ""); + } + { + using T = hana::tuple; + static_assert(sizeof(T) == sizeof(int), ""); + } + { + using T = hana::tuple; + static_assert(sizeof(T) == sizeof(int), ""); + } +} diff --git a/src/boost/libs/hana/test/tuple/hold_refs.cpp b/src/boost/libs/hana/test/tuple/hold_refs.cpp new file mode 100644 index 000000000..fb900194e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/hold_refs.cpp @@ -0,0 +1,78 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +// a non-movable, non-copyable type +struct RefOnly { + RefOnly() = default; + RefOnly(RefOnly const&) = delete; + RefOnly(RefOnly&&) = delete; +}; + +struct Empty { }; + +int main() { + // Make sure we can create a tuple of rvalue references + { + RefOnly e{}; + hana::tuple xs{std::move(e)}; + hana::tuple ys{std::move(e), std::move(e)}; + (void)xs; (void)ys; + + hana::tuple xs2 = {std::move(e)}; + hana::tuple ys2 = {std::move(e), std::move(e)}; + (void)xs2; (void)ys2; + } + + // Make sure we can create a tuple of non-const lvalue references + { + RefOnly e{}; + hana::tuple xs{e}; + hana::tuple ys{e, e}; + (void)xs; (void)ys; + + hana::tuple xs2 = {e}; + hana::tuple ys2 = {e, e}; + (void)xs2; (void)ys2; + } + + // Make sure we can create a tuple of const lvalue references + { + RefOnly const e{}; + hana::tuple xs{e}; + hana::tuple ys{e, e}; + (void)xs; (void)ys; + + hana::tuple xs2 = {e}; + hana::tuple ys2 = {e, e}; + (void)xs2; (void)ys2; + } + + // Try to construct tuples with mixed references and non-reference members. + { + RefOnly r{}; + Empty e{}; + + { + hana::tuple xs{r, e}; + hana::tuple ys = {r, e}; + (void)xs; (void)ys; + } + { + hana::tuple xs{r, e}; + hana::tuple ys = {r, e}; + (void)xs; (void)ys; + } + { + hana::tuple xs{std::move(r), e}; + hana::tuple ys = {std::move(r), e}; + (void)xs; (void)ys; + } + } +} diff --git a/src/boost/libs/hana/test/tuple/issue_90.cpp b/src/boost/libs/hana/test/tuple/issue_90.cpp new file mode 100644 index 000000000..ab78440d0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/issue_90.cpp @@ -0,0 +1,72 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template +T const& cref(T& t) { return t; } + +// a non-movable, non-copyable type +struct RefOnly { + RefOnly() = default; + RefOnly(RefOnly const&) = delete; + RefOnly(RefOnly&&) = delete; +}; + +template +struct RefOnly_i : hana::int_ { + RefOnly_i() = default; + RefOnly_i(RefOnly_i const&) = delete; + RefOnly_i(RefOnly_i&&) = delete; +}; + +int main() { + hana::tuple t; + + // Make sure that we return the proper reference types from `at`. + { + RefOnly&& r1 = hana::at_c<0>(std::move(t)); + RefOnly& r2 = hana::at_c<0>(t); + RefOnly const& r3 = hana::at_c<0>(cref(t)); + + (void)r1; (void)r2; (void)r3; + } + + // Make sure we return the proper reference types from `front`. + { + RefOnly&& r1 = hana::front(std::move(t)); + RefOnly& r2 = hana::front(t); + RefOnly const& r3 = hana::front(cref(t)); + + (void)r1; (void)r2; (void)r3; + } + + // Make sure we return the proper reference types from `back`. + { + RefOnly&& r1 = hana::back(std::move(t)); + RefOnly& r2 = hana::back(t); + RefOnly const& r3 = hana::back(cref(t)); + + (void)r1; (void)r2; (void)r3; + } + + // Make sure we return the proper reference types from `at_key`. + { + hana::tuple> t{}; + RefOnly_i<3>& r1 = hana::at_key(t, RefOnly_i<3>{}); + RefOnly_i<3> const& r2 = hana::at_key(cref(t), RefOnly_i<3>{}); + RefOnly_i<3>&& r3 = hana::at_key(std::move(t), RefOnly_i<3>{}); + + (void)r1; (void)r2; (void)r3; + } +} diff --git a/src/boost/libs/hana/test/tuple/laws.cpp b/src/boost/libs/hana/test/tuple/laws.cpp new file mode 100644 index 000000000..fc79fe9af --- /dev/null +++ b/src/boost/libs/hana/test/tuple/laws.cpp @@ -0,0 +1,43 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; +using hana::test::ct_ord; + + +int main() { + auto eq_tuples = hana::make_tuple( + hana::make_tuple() + , hana::make_tuple(ct_eq<0>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}) + ); + + auto ord_tuples = hana::make_tuple( + hana::make_tuple() + , hana::make_tuple(ct_ord<0>{}) + , hana::make_tuple(ct_ord<0>{}, ct_ord<1>{}) + , hana::make_tuple(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}) + , hana::make_tuple(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, ct_ord<3>{}) + , hana::make_tuple(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, ct_ord<3>{}, ct_ord<4>{}) + ); + + hana::test::TestComparable{eq_tuples}; + hana::test::TestOrderable{ord_tuples}; + hana::test::TestFoldable{eq_tuples}; + hana::test::TestIterable{eq_tuples}; + hana::test::TestSequence{}; +} diff --git a/src/boost/libs/hana/test/tuple/laws.functor.cpp b/src/boost/libs/hana/test/tuple/laws.functor.cpp new file mode 100644 index 000000000..7a72d2d56 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/laws.functor.cpp @@ -0,0 +1,64 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto eq_tuples = hana::make_tuple( + hana::make_tuple() + , hana::make_tuple(ct_eq<0>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}) + ); + + auto eq_values = hana::make_tuple( + ct_eq<0>{}, + ct_eq<2>{}, + ct_eq<4>{} + ); + + auto predicates = hana::make_tuple( + hana::equal.to(ct_eq<0>{}), + hana::equal.to(ct_eq<2>{}), + hana::equal.to(ct_eq<4>{}), + hana::always(hana::true_c), + hana::always(hana::false_c) + ); + + auto nested_eqs = hana::make_tuple( + hana::make_tuple() + , hana::make_tuple( + hana::make_tuple(ct_eq<0>{}) + ) + , hana::make_tuple( + hana::make_tuple(ct_eq<0>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}) + ) + , hana::make_tuple( + hana::make_tuple(ct_eq<0>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<3>{}, ct_eq<4>{}) + ) + ); + + hana::test::TestFunctor{eq_tuples, eq_values}; + hana::test::TestApplicative{eq_tuples}; + hana::test::TestMonad{eq_tuples, nested_eqs}; + hana::test::TestMonadPlus{eq_tuples, predicates, eq_values}; +} diff --git a/src/boost/libs/hana/test/tuple/laws.searchable.cpp b/src/boost/libs/hana/test/tuple/laws.searchable.cpp new file mode 100644 index 000000000..6aa096899 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/laws.searchable.cpp @@ -0,0 +1,40 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto eq_tuples = hana::make_tuple( + hana::make_tuple() + , hana::make_tuple(ct_eq<0>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + ); + hana::test::TestSearchable{ + eq_tuples, + hana::make_tuple(ct_eq<3>{}, ct_eq<5>{}) + }; + + auto bool_tuples = hana::make_tuple( + hana::make_tuple(hana::true_c) + , hana::make_tuple(hana::false_c) + , hana::make_tuple(hana::true_c, hana::true_c) + , hana::make_tuple(hana::true_c, hana::false_c) + , hana::make_tuple(hana::false_c, hana::true_c) + , hana::make_tuple(hana::false_c, hana::false_c) + ); + hana::test::TestSearchable{ + bool_tuples, + hana::make_tuple(hana::true_c, hana::false_c) + }; +} diff --git a/src/boost/libs/hana/test/tuple/move_only.cpp b/src/boost/libs/hana/test/tuple/move_only.cpp new file mode 100644 index 000000000..3f78316cc --- /dev/null +++ b/src/boost/libs/hana/test/tuple/move_only.cpp @@ -0,0 +1,55 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +// This test checks for move-only friendliness and reference semantics. + +struct MoveOnly { + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; + MoveOnly& operator=(MoveOnly&&) = default; + + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; +}; + +int main() { + { + auto xs = hana::make_tuple(MoveOnly{}); + auto by_val = [](auto) { }; + + by_val(std::move(xs)); + by_val(hana::front(std::move(xs))); + by_val(hana::at_c<0>(std::move(xs))); + by_val(hana::back(std::move(xs))); + } + + { + auto const& xs = hana::make_tuple(MoveOnly{}); + auto by_const_ref = [](auto const&) { }; + + by_const_ref(xs); + by_const_ref(hana::front(xs)); + by_const_ref(hana::at_c<0>(xs)); + by_const_ref(hana::back(xs)); + } + + { + auto xs = hana::make_tuple(MoveOnly{}); + auto by_ref = [](auto&) { }; + + by_ref(xs); + by_ref(hana::front(xs)); + by_ref(hana::at_c<0>(xs)); + by_ref(hana::back(xs)); + } +} diff --git a/src/boost/libs/hana/test/tuple/pair_interop.cpp b/src/boost/libs/hana/test/tuple/pair_interop.cpp new file mode 100644 index 000000000..1e079f437 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/pair_interop.cpp @@ -0,0 +1,75 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +// This test makes sure that tuples containing pairs behave properly. It is +// useful to test this specific case because tuple and pair (may) share a lot +// of implementation details (for EBO), and that can easily lead to subtle bugs. +// For example, if both pair and tuple inherit from similar base classes for +// EBO, accessing a tuple of pairs or a pair of tuples (which requires some +// base class casting magic) can lead to ambiguous overloads. + +int main() { + struct empty1 { }; + struct empty2 { }; + + { + hana::tuple> t{}; + hana::first(hana::at_c<0>(t)); + hana::second(hana::at_c<0>(t)); + } + { + hana::tuple> t{}; + hana::first(hana::at_c<0>(t)); + hana::second(hana::at_c<0>(t)); + } + { + hana::tuple> t{}; + hana::first(hana::at_c<0>(t)); + hana::second(hana::at_c<0>(t)); + } + { + hana::tuple> t{}; + hana::first(hana::at_c<0>(t)); + hana::second(hana::at_c<0>(t)); + } + + { + hana::pair, hana::tuple<>> p{}; + hana::first(p); + hana::second(p); + } + { + hana::pair, hana::tuple> p{}; + hana::first(p); + hana::second(p); + } + { + hana::pair, hana::tuple> p{}; + hana::first(p); + hana::second(p); + } + { + hana::pair, hana::tuple> p{}; + hana::first(p); + hana::second(p); + } + { + hana::pair, hana::tuple> p{}; + hana::first(p); + hana::second(p); + } + { + hana::pair, hana::tuple> p{}; + hana::first(p); + hana::second(p); + } +} diff --git a/src/boost/libs/hana/test/tuple/smart_ptr.cpp b/src/boost/libs/hana/test/tuple/smart_ptr.cpp new file mode 100644 index 000000000..aea7dc857 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/smart_ptr.cpp @@ -0,0 +1,23 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +// Tuples of smart pointers; based on LLVM bug #18350 +int main() { + { + hana::tuple> up; + hana::tuple> sp; + hana::tuple> wp; + } + { + hana::tuple> up; + hana::tuple> sp; + hana::tuple> wp; + } +} diff --git a/src/boost/libs/hana/test/tuple/special.drop_front_exactly.cpp b/src/boost/libs/hana/test/tuple/special.drop_front_exactly.cpp new file mode 100644 index 000000000..1092c5216 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.drop_front_exactly.cpp @@ -0,0 +1,46 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct x0; +struct x1; +struct x2; + +int main() { + // tuple_t + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_t), + hana::tuple_t<> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_t), + hana::tuple_t + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_t), + hana::tuple_t + )); + + // tuple_c + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_c), + hana::tuple_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_c), + hana::tuple_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_c), + hana::tuple_c + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.empty.cpp b/src/boost/libs/hana/test/tuple/special.empty.cpp new file mode 100644 index 000000000..2cbb36d31 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.empty.cpp @@ -0,0 +1,25 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::empty(), + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::empty(), + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::empty(), + hana::tuple_c + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.equal.cpp b/src/boost/libs/hana/test/tuple/special.equal.cpp new file mode 100644 index 000000000..27694f2bc --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.equal.cpp @@ -0,0 +1,76 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct x0; +struct x1; +struct x2; + +int main() { + // tuple_t + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_t<>, + hana::tuple_t<> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_t, + hana::tuple_t<>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_t<>, + hana::tuple_t) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_t, + hana::tuple_t + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_t, + hana::tuple_t) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_t, + hana::tuple_t) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_t, + hana::tuple_t + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_t, + hana::tuple_t + )); + + // tuple_c + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_c, + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_c, + hana::tuple_c + ))); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_c, + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_c, + hana::tuple_c + ))); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_c, + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_c, + hana::tuple_c + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.fill.cpp b/src/boost/libs/hana/test/tuple/special.fill.cpp new file mode 100644 index 000000000..d764083fb --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.fill.cpp @@ -0,0 +1,36 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct x1; +struct x2; +struct x3; +struct z; + +int main() { + // fill a tuple_t with a hana::type + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fill(hana::tuple_t<>, hana::type_c), + hana::tuple_t<> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fill(hana::tuple_t, hana::type_c), + hana::tuple_t + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fill(hana::tuple_t, hana::type_c), + hana::tuple_t + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fill(hana::tuple_t, hana::type_c), + hana::tuple_t + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.fold_left.cpp b/src/boost/libs/hana/test/tuple/special.fold_left.cpp new file mode 100644 index 000000000..cf121ebb8 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.fold_left.cpp @@ -0,0 +1,68 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +struct F { struct type; }; + +struct x0; +struct x1; +struct x2; +struct x3; + +int main() { + // tuple_t and initial state + { + auto f = hana::metafunction; + auto s = hana::type_c; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t<>, s, f), + s + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, s, f), + f(s, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, s, f), + f(f(s, hana::type_c), hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, s, f), + f(f(f(s, hana::type_c), hana::type_c), hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, s, f), + f(f(f(f(s, hana::type_c), hana::type_c), hana::type_c), hana::type_c) + )); + } + + // tuple_t and no initial state + { + auto f = hana::metafunction; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, f), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, f), + f(hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, f), + f(f(hana::type_c, hana::type_c), hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, f), + f(f(f(hana::type_c, hana::type_c), hana::type_c), hana::type_c) + )); + } +} diff --git a/src/boost/libs/hana/test/tuple/special.fold_right.cpp b/src/boost/libs/hana/test/tuple/special.fold_right.cpp new file mode 100644 index 000000000..a78d40ed3 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.fold_right.cpp @@ -0,0 +1,68 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +struct F { struct type; }; + +struct x0; +struct x1; +struct x2; +struct x3; + +int main() { + // tuple_t and an initial state + { + auto f = hana::metafunction; + auto s = hana::type_c; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t<>, s, f), + s + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, s, f), + f(hana::type_c, s) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, s, f), + f(hana::type_c, f(hana::type_c, s)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, s, f), + f(hana::type_c, f(hana::type_c, f(hana::type_c, s))) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, s, f), + f(hana::type_c, f(hana::type_c, f(hana::type_c, f(hana::type_c, s)))) + )); + } + + // tuple_t and no initial state + { + auto f = hana::metafunction; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, f), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, f), + f(hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, f), + f(hana::type_c, f(hana::type_c, hana::type_c)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, f), + f(hana::type_c, f(hana::type_c, f(hana::type_c, hana::type_c))) + )); + } +} diff --git a/src/boost/libs/hana/test/tuple/special.front.cpp b/src/boost/libs/hana/test/tuple/special.front.cpp new file mode 100644 index 000000000..9dc712d5c --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.front.cpp @@ -0,0 +1,46 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct x0; +struct x1; +struct x2; + +int main() { + // tuple_t + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_t), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_t), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_t), + hana::type_c + )); + + // tuple_c + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_c), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_c), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_c), + hana::int_c<0> + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.is_empty.cpp b/src/boost/libs/hana/test/tuple/special.is_empty.cpp new file mode 100644 index 000000000..3bf0cf780 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.is_empty.cpp @@ -0,0 +1,28 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct x0; +struct x1; +struct x2; + +int main() { + // tuple_t + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::tuple_t<>)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_t))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_t))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_t))); + + // tuple_c + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::tuple_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_c))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_c))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_c))); +} diff --git a/src/boost/libs/hana/test/tuple/special.prepend.cpp b/src/boost/libs/hana/test/tuple/special.prepend.cpp new file mode 100644 index 000000000..267f7dd4e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.prepend.cpp @@ -0,0 +1,30 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::prepend(hana::tuple_c, hana::long_c<0>), + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::prepend(hana::tuple_c, hana::uint_c<0>), + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::prepend(hana::tuple_c, hana::llong_c<0>), + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::prepend(hana::tuple_c, hana::ulong_c<0>), + hana::tuple_c + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.transform.cpp b/src/boost/libs/hana/test/tuple/special.transform.cpp new file mode 100644 index 000000000..86d141c6e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.transform.cpp @@ -0,0 +1,52 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +struct F { struct type; }; + +struct x1; +struct x2; +struct x3; +struct x4; + +int main() { + // transform with tuple_t and a metafunction + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t<>, hana::metafunction), + hana::tuple_t<> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t, hana::metafunction), + hana::tuple_t::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t, hana::metafunction), + hana::tuple_t::type, F::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t, hana::metafunction), + hana::tuple_t::type, F::type, F::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t, hana::metafunction), + hana::tuple_t::type, F::type, F::type, F::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t, hana::template_), + hana::tuple_t, F, F, F> + )); +} diff --git a/src/boost/libs/hana/test/tuple/to.cpp b/src/boost/libs/hana/test/tuple/to.cpp new file mode 100644 index 000000000..d0862c3c2 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/to.cpp @@ -0,0 +1,18 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + // make sure to_tuple == to + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(hana::tuple_t), + hana::to_tuple(hana::tuple_t) + )); +} diff --git a/src/boost/libs/hana/test/tuple/unpack.cpp b/src/boost/libs/hana/test/tuple/unpack.cpp new file mode 100644 index 000000000..3838ea299 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/unpack.cpp @@ -0,0 +1,89 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +template +struct F { struct type; }; + +struct x0; +struct x1; +struct x2; +struct x3; + +int main() { + hana::test::_injection<0> f{}; + + // tuple + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_tuple(), f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_tuple(ct_eq<0>{}), f), + f(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}), f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + // tuple_t + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t<>, f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, f), + f(hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, f), + f(hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, f), + f(hana::type_c, hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, f), + f(hana::type_c, hana::type_c, hana::type_c, hana::type_c) + )); + + // tuple_t with metafunction + auto g = hana::metafunction; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t<>, g), + g() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, g), + g(hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, g), + g(hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, g), + g(hana::type_c, hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, g), + g(hana::type_c, hana::type_c, hana::type_c, hana::type_c) + )); +} diff --git a/src/boost/libs/hana/test/tuple/usability_of_types.cpp b/src/boost/libs/hana/test/tuple/usability_of_types.cpp new file mode 100644 index 000000000..261b47ad0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/usability_of_types.cpp @@ -0,0 +1,41 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +// The fact that a reference to a `type<...>` is returned from `front(types)` +// and friends used to break the `decltype(front(types))::type` pattern, +// because we would be trying to fetch `::type` inside a reference. To work +// around this, a unary `operator+` turning a lvalue `type` into a rvalue +// `type` was added. + +struct T; struct U; struct V; + +int main() { + auto check = [](auto types) { + static_assert(std::is_same< + typename decltype(+hana::front(types))::type, T + >{}, ""); + + static_assert(std::is_same< + typename decltype(+hana::at(types, hana::size_c<1>))::type, U + >{}, ""); + + static_assert(std::is_same< + typename decltype(+hana::back(types))::type, V + >{}, ""); + }; + + check(hana::make_tuple(hana::type_c, hana::type_c, hana::type_c)); + check(hana::tuple_t); +} -- cgit v1.2.3