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/example/ext/boost/fusion/deque.cpp | 35 +++++++++++++ .../libs/hana/example/ext/boost/fusion/list.cpp | 35 +++++++++++++ .../libs/hana/example/ext/boost/fusion/tuple.cpp | 35 +++++++++++++ .../libs/hana/example/ext/boost/fusion/vector.cpp | 35 +++++++++++++ .../ext/boost/mpl/integral_c/integral_constant.cpp | 24 +++++++++ .../hana/example/ext/boost/mpl/list/comparable.cpp | 22 +++++++++ .../hana/example/ext/boost/mpl/list/conversion.cpp | 22 +++++++++ .../hana/example/ext/boost/mpl/list/foldable.cpp | 31 ++++++++++++ .../hana/example/ext/boost/mpl/list/iterable.cpp | 33 +++++++++++++ .../hana/example/ext/boost/mpl/list/searchable.cpp | 30 ++++++++++++ .../example/ext/boost/mpl/vector/comparable.cpp | 22 +++++++++ .../example/ext/boost/mpl/vector/conversion.cpp | 22 +++++++++ .../hana/example/ext/boost/mpl/vector/foldable.cpp | 31 ++++++++++++ .../hana/example/ext/boost/mpl/vector/iterable.cpp | 33 +++++++++++++ .../example/ext/boost/mpl/vector/searchable.cpp | 30 ++++++++++++ src/boost/libs/hana/example/ext/boost/tuple.cpp | 33 +++++++++++++ .../libs/hana/example/ext/std/array/comparable.cpp | 24 +++++++++ .../libs/hana/example/ext/std/array/foldable.cpp | 21 ++++++++ .../libs/hana/example/ext/std/array/iterable.cpp | 20 ++++++++ .../libs/hana/example/ext/std/array/orderable.cpp | 23 +++++++++ .../ext/std/integer_sequence/comparable.cpp | 22 +++++++++ .../example/ext/std/integer_sequence/foldable.cpp | 25 ++++++++++ .../example/ext/std/integer_sequence/iterable.cpp | 23 +++++++++ .../ext/std/integer_sequence/searchable.cpp | 25 ++++++++++ .../hana/example/ext/std/integral_constant.cpp | 22 +++++++++ src/boost/libs/hana/example/ext/std/pair.cpp | 21 ++++++++ .../libs/hana/example/ext/std/ratio/arithmetic.cpp | 57 ++++++++++++++++++++++ .../libs/hana/example/ext/std/ratio/comparable.cpp | 17 +++++++ .../libs/hana/example/ext/std/ratio/orderable.cpp | 17 +++++++ src/boost/libs/hana/example/ext/std/tuple.cpp | 32 ++++++++++++ 30 files changed, 822 insertions(+) create mode 100644 src/boost/libs/hana/example/ext/boost/fusion/deque.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/fusion/list.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/fusion/tuple.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/fusion/vector.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/integral_c/integral_constant.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/list/comparable.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/list/conversion.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/list/foldable.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/list/iterable.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/list/searchable.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/vector/comparable.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/vector/conversion.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/vector/foldable.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/vector/iterable.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/mpl/vector/searchable.cpp create mode 100644 src/boost/libs/hana/example/ext/boost/tuple.cpp create mode 100644 src/boost/libs/hana/example/ext/std/array/comparable.cpp create mode 100644 src/boost/libs/hana/example/ext/std/array/foldable.cpp create mode 100644 src/boost/libs/hana/example/ext/std/array/iterable.cpp create mode 100644 src/boost/libs/hana/example/ext/std/array/orderable.cpp create mode 100644 src/boost/libs/hana/example/ext/std/integer_sequence/comparable.cpp create mode 100644 src/boost/libs/hana/example/ext/std/integer_sequence/foldable.cpp create mode 100644 src/boost/libs/hana/example/ext/std/integer_sequence/iterable.cpp create mode 100644 src/boost/libs/hana/example/ext/std/integer_sequence/searchable.cpp create mode 100644 src/boost/libs/hana/example/ext/std/integral_constant.cpp create mode 100644 src/boost/libs/hana/example/ext/std/pair.cpp create mode 100644 src/boost/libs/hana/example/ext/std/ratio/arithmetic.cpp create mode 100644 src/boost/libs/hana/example/ext/std/ratio/comparable.cpp create mode 100644 src/boost/libs/hana/example/ext/std/ratio/orderable.cpp create mode 100644 src/boost/libs/hana/example/ext/std/tuple.cpp (limited to 'src/boost/libs/hana/example/ext') diff --git a/src/boost/libs/hana/example/ext/boost/fusion/deque.cpp b/src/boost/libs/hana/example/ext/boost/fusion/deque.cpp new file mode 100644 index 000000000..965e78472 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/fusion/deque.cpp @@ -0,0 +1,35 @@ +// 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 +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +struct Fish { std::string name; }; +struct Cat { std::string name; }; +struct Dog { std::string name; }; + +int main() { + fusion::deque animals{{"Nemo"}, {"Garfield"}, {"Snoopy"}}; + hana::front(animals).name = "Moby Dick"; + + auto names = hana::transform(animals, [](auto a) { + return a.name; + }); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + names, + fusion::make_deque("Moby Dick", "Garfield", "Snoopy") + )); +} diff --git a/src/boost/libs/hana/example/ext/boost/fusion/list.cpp b/src/boost/libs/hana/example/ext/boost/fusion/list.cpp new file mode 100644 index 000000000..dbd2cfc7e --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/fusion/list.cpp @@ -0,0 +1,35 @@ +// 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 +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +struct Fish { std::string name; }; +struct Cat { std::string name; }; +struct Dog { std::string name; }; + +int main() { + fusion::list animals{{"Nemo"}, {"Garfield"}, {"Snoopy"}}; + hana::front(animals).name = "Moby Dick"; + + auto names = hana::transform(animals, [](auto a) { + return a.name; + }); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + names, + fusion::make_list("Moby Dick", "Garfield", "Snoopy") + )); +} diff --git a/src/boost/libs/hana/example/ext/boost/fusion/tuple.cpp b/src/boost/libs/hana/example/ext/boost/fusion/tuple.cpp new file mode 100644 index 000000000..2c4743b06 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/fusion/tuple.cpp @@ -0,0 +1,35 @@ +// 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 +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +struct Fish { std::string name; }; +struct Cat { std::string name; }; +struct Dog { std::string name; }; + +int main() { + fusion::tuple animals{Fish{"Nemo"}, Cat{"Garfield"}, Dog{"Snoopy"}}; + hana::front(animals).name = "Moby Dick"; + + auto names = hana::transform(animals, [](auto a) { + return a.name; + }); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + names, + fusion::make_tuple("Moby Dick", "Garfield", "Snoopy") + )); +} diff --git a/src/boost/libs/hana/example/ext/boost/fusion/vector.cpp b/src/boost/libs/hana/example/ext/boost/fusion/vector.cpp new file mode 100644 index 000000000..fd2f115b1 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/fusion/vector.cpp @@ -0,0 +1,35 @@ +// 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 +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +struct Fish { std::string name; }; +struct Cat { std::string name; }; +struct Dog { std::string name; }; + +int main() { + fusion::vector animals{Fish{"Nemo"}, Cat{"Garfield"}, Dog{"Snoopy"}}; + hana::front(animals).name = "Moby Dick"; + + auto names = hana::transform(animals, [](auto a) { + return a.name; + }); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + names, + fusion::make_vector("Moby Dick", "Garfield", "Snoopy") + )); +} diff --git a/src/boost/libs/hana/example/ext/boost/mpl/integral_c/integral_constant.cpp b/src/boost/libs/hana/example/ext/boost/mpl/integral_c/integral_constant.cpp new file mode 100644 index 000000000..e4b781350 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/integral_c/integral_constant.cpp @@ -0,0 +1,24 @@ +// 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; +namespace mpl = boost::mpl; + + +static_assert(hana::value(mpl::integral_c{}) == 3, ""); +static_assert(mpl::integral_c::value == 3, ""); + +BOOST_HANA_CONSTANT_CHECK(hana::equal(mpl::integral_c{}, mpl::int_<3>{})); +BOOST_HANA_CONSTANT_CHECK(hana::equal(mpl::integral_c{}, mpl::long_<3>{})); +BOOST_HANA_CONSTANT_CHECK(hana::not_equal(mpl::integral_c{}, mpl::int_<0>{})); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/mpl/list/comparable.cpp b/src/boost/libs/hana/example/ext/boost/mpl/list/comparable.cpp new file mode 100644 index 000000000..7f2816488 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/list/comparable.cpp @@ -0,0 +1,22 @@ +// 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; +namespace mpl = boost::mpl; + + +BOOST_HANA_CONSTANT_CHECK( + hana::equal(mpl::list2{}, mpl::list{}) +); +BOOST_HANA_CONSTANT_CHECK( + hana::not_equal(mpl::list2{}, mpl::list{}) +); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/mpl/list/conversion.cpp b/src/boost/libs/hana/example/ext/boost/mpl/list/conversion.cpp new file mode 100644 index 000000000..2bed05599 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/list/conversion.cpp @@ -0,0 +1,22 @@ +// 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; +namespace mpl = boost::mpl; + + +auto xs = hana::make_tuple(hana::type_c, hana::type_c, hana::type_c); +static_assert(std::is_same< + decltype(hana::to(xs)), + mpl::list +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/mpl/list/foldable.cpp b/src/boost/libs/hana/example/ext/boost/mpl/list/foldable.cpp new file mode 100644 index 000000000..6f21fdc88 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/list/foldable.cpp @@ -0,0 +1,31 @@ +// 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 + +#include +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +auto types = mpl::list{}; +auto number_of_floats = hana::fold_left(types, hana::int_c<0>, [](auto count, auto t) { + return hana::if_(hana::trait(t), + count + hana::int_c<1>, + count + ); +}); + +BOOST_HANA_CONSTANT_CHECK(number_of_floats == hana::int_c<3>); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/mpl/list/iterable.cpp b/src/boost/libs/hana/example/ext/boost/mpl/list/iterable.cpp new file mode 100644 index 000000000..87a803c20 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/list/iterable.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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +BOOST_HANA_CONSTANT_CHECK(hana::front(mpl::list{}) == hana::type_c); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(mpl::list{}), + mpl::list{} +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(mpl::list{}, + hana::trait), + mpl::list{} +)); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/mpl/list/searchable.cpp b/src/boost/libs/hana/example/ext/boost/mpl/list/searchable.cpp new file mode 100644 index 000000000..4ce0fd775 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/list/searchable.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 +#include +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +BOOST_HANA_CONSTANT_CHECK( + hana::find_if(mpl::list{}, hana::equal.to(hana::type_c)) + == + hana::just(hana::type_c) +); + +BOOST_HANA_CONSTANT_CHECK( + hana::find(mpl::list{}, hana::type_c) + == + hana::nothing +); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/mpl/vector/comparable.cpp b/src/boost/libs/hana/example/ext/boost/mpl/vector/comparable.cpp new file mode 100644 index 000000000..c5e936f50 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/vector/comparable.cpp @@ -0,0 +1,22 @@ +// 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; +namespace mpl = boost::mpl; + + +BOOST_HANA_CONSTANT_CHECK( + hana::equal(mpl::vector2{}, mpl::vector{}) +); +BOOST_HANA_CONSTANT_CHECK( + hana::not_equal(mpl::vector2{}, mpl::vector{}) +); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/mpl/vector/conversion.cpp b/src/boost/libs/hana/example/ext/boost/mpl/vector/conversion.cpp new file mode 100644 index 000000000..7319f2009 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/vector/conversion.cpp @@ -0,0 +1,22 @@ +// 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; +namespace mpl = boost::mpl; + + +auto xs = hana::make_tuple(hana::type_c, hana::type_c, hana::type_c); +static_assert(std::is_same< + decltype(hana::to(xs)), + mpl::vector +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/mpl/vector/foldable.cpp b/src/boost/libs/hana/example/ext/boost/mpl/vector/foldable.cpp new file mode 100644 index 000000000..eb9411a6c --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/vector/foldable.cpp @@ -0,0 +1,31 @@ +// 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 + +#include +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +auto types = mpl::vector{}; +auto number_of_floats = hana::fold_left(types, hana::int_c<0>, [](auto count, auto t) { + return hana::if_(hana::trait(t), + count + hana::int_c<1>, + count + ); +}); + +BOOST_HANA_CONSTANT_CHECK(number_of_floats == hana::int_c<3>); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/mpl/vector/iterable.cpp b/src/boost/libs/hana/example/ext/boost/mpl/vector/iterable.cpp new file mode 100644 index 000000000..c6751a3b7 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/vector/iterable.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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +BOOST_HANA_CONSTANT_CHECK(hana::front(mpl::vector{}) == hana::type_c); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(mpl::vector{}), + mpl::vector{} +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(mpl::vector{}, + hana::trait), + mpl::vector{} +)); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/mpl/vector/searchable.cpp b/src/boost/libs/hana/example/ext/boost/mpl/vector/searchable.cpp new file mode 100644 index 000000000..476949925 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/mpl/vector/searchable.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 +#include +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +BOOST_HANA_CONSTANT_CHECK( + hana::find_if(mpl::vector{}, hana::equal.to(hana::type_c)) + == + hana::just(hana::type_c) +); + +BOOST_HANA_CONSTANT_CHECK( + hana::find(mpl::vector{}, hana::type_c) + == + hana::nothing +); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/boost/tuple.cpp b/src/boost/libs/hana/example/ext/boost/tuple.cpp new file mode 100644 index 000000000..319e80834 --- /dev/null +++ b/src/boost/libs/hana/example/ext/boost/tuple.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 +#include +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; + + +struct Fish { std::string name; }; +struct Cat { std::string name; }; +struct Dog { std::string name; }; + +int main() { + boost::tuple animals{{"Nemo"}, {"Garfield"}, {"Snoopy"}}; + hana::front(animals).name = "Moby Dick"; + + auto names = hana::transform(animals, [](auto a) { + return a.name; + }); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + names, + boost::make_tuple("Moby Dick", "Garfield", "Snoopy") + )); +} diff --git a/src/boost/libs/hana/example/ext/std/array/comparable.cpp b/src/boost/libs/hana/example/ext/std/array/comparable.cpp new file mode 100644 index 000000000..c1c814877 --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/array/comparable.cpp @@ -0,0 +1,24 @@ +// 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; + + +constexpr std::array xs = {{1, 2, 3, 4}}; +constexpr std::array ys = {{1, 2, 3, 4, 5}}; + +// arrays have different constexpr contents; result is a constexpr bool +static_assert(hana::equal(xs, xs), ""); + +// arrays have different lengths; result is an integral_constant +BOOST_HANA_CONSTANT_CHECK(hana::not_equal(xs, ys)); + + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/array/foldable.cpp b/src/boost/libs/hana/example/ext/std/array/foldable.cpp new file mode 100644 index 000000000..cff38e1c1 --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/array/foldable.cpp @@ -0,0 +1,21 @@ +// 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() { + std::array a = {{0, 1, 2, 3, 4}}; + + auto b = hana::unpack(a, [](auto ...i) { + return std::array{{(i + 10)...}}; + }); + + BOOST_HANA_RUNTIME_CHECK(b == std::array{{10, 11, 12, 13, 14}}); +} diff --git a/src/boost/libs/hana/example/ext/std/array/iterable.cpp b/src/boost/libs/hana/example/ext/std/array/iterable.cpp new file mode 100644 index 000000000..d14dbd911 --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/array/iterable.cpp @@ -0,0 +1,20 @@ +// 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; + + +constexpr std::array a = {{0, 1, 2, 3, 4}}; + +static_assert(hana::at_c<2>(a) == 2, ""); + +static_assert(hana::equal(hana::drop_front(a), std::array{{1, 2, 3, 4}}), ""); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/array/orderable.cpp b/src/boost/libs/hana/example/ext/std/array/orderable.cpp new file mode 100644 index 000000000..7f4c9f2b7 --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/array/orderable.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 + +#include +namespace hana = boost::hana; + + +constexpr std::array evens = {{2, 4, 6, 8}}; +constexpr std::array odds = {{1, 3, 5, 7}}; + +constexpr std::array up_to_5 = {{1, 2, 3, 4, 5}}; + +// arrays with same length +static_assert(hana::less(odds, evens), ""); + +// arrays with different lengths +static_assert(hana::less(up_to_5, odds), ""); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/integer_sequence/comparable.cpp b/src/boost/libs/hana/example/ext/std/integer_sequence/comparable.cpp new file mode 100644 index 000000000..10b62752a --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/integer_sequence/comparable.cpp @@ -0,0 +1,22 @@ +// 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; + + +constexpr std::integer_sequence xs{}; +constexpr std::integer_sequence ys{}; +constexpr std::integer_sequence zs{}; + +BOOST_HANA_CONSTANT_CHECK(hana::equal(xs, ys)); +BOOST_HANA_CONSTANT_CHECK(hana::not_equal(xs, zs)); +BOOST_HANA_CONSTANT_CHECK(hana::not_equal(ys, zs)); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/integer_sequence/foldable.cpp b/src/boost/libs/hana/example/ext/std/integer_sequence/foldable.cpp new file mode 100644 index 000000000..4d7c3253f --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/integer_sequence/foldable.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 +#include +namespace hana = boost::hana; + + +auto add = [](auto a, auto b, auto c) { return a + b + c; }; + +int main() { + std::tuple tuple{1, 2l, 3.3}; + + auto sum = hana::unpack(std::integer_sequence{}, [&](auto ...i) { + // the `i`s are `std::integral_constant`s + return add(std::get(tuple)...); + }); + + BOOST_HANA_RUNTIME_CHECK(sum == 6.3); +} diff --git a/src/boost/libs/hana/example/ext/std/integer_sequence/iterable.cpp b/src/boost/libs/hana/example/ext/std/integer_sequence/iterable.cpp new file mode 100644 index 000000000..ef421ec37 --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/integer_sequence/iterable.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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +constexpr std::integer_sequence indices{}; + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<2>(indices), + std::integral_constant{} +)); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/integer_sequence/searchable.cpp b/src/boost/libs/hana/example/ext/std/integer_sequence/searchable.cpp new file mode 100644 index 000000000..c0a159bc8 --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/integer_sequence/searchable.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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +constexpr std::integer_sequence xs{}; + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(xs, hana::int_c<3>), + hana::just(std::integral_constant{}) +)); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/integral_constant.cpp b/src/boost/libs/hana/example/ext/std/integral_constant.cpp new file mode 100644 index 000000000..04e234f1a --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/integral_constant.cpp @@ -0,0 +1,22 @@ +// 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; + + +static_assert(hana::value(std::integral_constant{}) == 3, ""); +static_assert(std::integral_constant::value == 3, ""); + +BOOST_HANA_CONSTANT_CHECK(hana::equal(std::integral_constant{}, hana::int_c<3>)); +BOOST_HANA_CONSTANT_CHECK(hana::equal(std::integral_constant{}, hana::long_c<3>)); +BOOST_HANA_CONSTANT_CHECK(hana::not_equal(std::integral_constant{}, hana::int_c<0>)); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/pair.cpp b/src/boost/libs/hana/example/ext/std/pair.cpp new file mode 100644 index 000000000..d118b18f8 --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/pair.cpp @@ -0,0 +1,21 @@ +// 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; + + +constexpr auto pair = std::make_pair(1, 'x'); + +static_assert(hana::first(pair) == 1, ""); +static_assert(hana::second(pair) == 'x', ""); + +static_assert(hana::not_equal(pair, std::make_pair(3, 'z')), ""); +static_assert(hana::less(pair, std::make_pair(3, 'x')), ""); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/ratio/arithmetic.cpp b/src/boost/libs/hana/example/ext/std/ratio/arithmetic.cpp new file mode 100644 index 000000000..7bcdbbd3f --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/ratio/arithmetic.cpp @@ -0,0 +1,57 @@ +// 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 +#include + +#include +namespace hana = boost::hana; + + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::plus(std::ratio<5, 3>{}, std::ratio<3, 12>{}), + std::ratio<23, 12>{} +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::minus(std::ratio<5, 3>{}, std::ratio<3, 13>{}), + std::ratio<56, 39>{} +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::mult(std::ratio<5, 3>{}, std::ratio<3, 13>{}), + std::ratio<15, 39>{} +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::div(std::ratio<5, 3>{}, std::ratio<3, 13>{}), + std::ratio<65, 9>{} +)); + +// The mod of two ratios is always 0, because they can always be +// divided without remainder. +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::mod(std::ratio<5, 3>{}, std::ratio<3, 13>{}), + std::ratio<0>{} +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zero(), + std::ratio<0>{} +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::one(), + std::ratio<1>{} +)); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/ratio/comparable.cpp b/src/boost/libs/hana/example/ext/std/ratio/comparable.cpp new file mode 100644 index 000000000..05d64de32 --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/ratio/comparable.cpp @@ -0,0 +1,17 @@ +// 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; + + +BOOST_HANA_CONSTANT_CHECK(hana::equal(std::ratio<3, 4>{}, std::ratio<15, 20>{})); +BOOST_HANA_CONSTANT_CHECK(hana::not_equal(std::ratio<3, 4>{}, std::ratio<3, 5>{})); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/ratio/orderable.cpp b/src/boost/libs/hana/example/ext/std/ratio/orderable.cpp new file mode 100644 index 000000000..7764bb12a --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/ratio/orderable.cpp @@ -0,0 +1,17 @@ +// 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; + + +BOOST_HANA_CONSTANT_CHECK(hana::less(std::ratio<3, 12>{}, std::ratio<5, 12>{})); +BOOST_HANA_CONSTANT_CHECK(hana::less_equal(std::ratio<6, 12>{}, std::ratio<4, 8>{})); + +int main() { } diff --git a/src/boost/libs/hana/example/ext/std/tuple.cpp b/src/boost/libs/hana/example/ext/std/tuple.cpp new file mode 100644 index 000000000..d545d6fb4 --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/tuple.cpp @@ -0,0 +1,32 @@ +// 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; + + +struct Fish { std::string name; }; +struct Cat { std::string name; }; +struct Dog { std::string name; }; + +int main() { + std::tuple animals{{"Nemo"}, {"Garfield"}, {"Snoopy"}}; + hana::front(animals).name = "Moby Dick"; + + auto names = hana::transform(animals, [](auto a) { + return a.name; + }); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + names, + std::make_tuple("Moby Dick", "Garfield", "Snoopy") + )); +} -- cgit v1.2.3