diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/example/set | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/hana/example/set')
-rw-r--r-- | src/boost/libs/hana/example/set/comparable.cpp | 26 | ||||
-rw-r--r-- | src/boost/libs/hana/example/set/difference.cpp | 20 | ||||
-rw-r--r-- | src/boost/libs/hana/example/set/erase_key.cpp | 19 | ||||
-rw-r--r-- | src/boost/libs/hana/example/set/foldable.cpp | 20 | ||||
-rw-r--r-- | src/boost/libs/hana/example/set/insert.cpp | 25 | ||||
-rw-r--r-- | src/boost/libs/hana/example/set/intersection.cpp | 19 | ||||
-rw-r--r-- | src/boost/libs/hana/example/set/make.cpp | 17 | ||||
-rw-r--r-- | src/boost/libs/hana/example/set/searchable.cpp | 25 | ||||
-rw-r--r-- | src/boost/libs/hana/example/set/symmetric_difference.cpp | 19 | ||||
-rw-r--r-- | src/boost/libs/hana/example/set/to.cpp | 28 | ||||
-rw-r--r-- | src/boost/libs/hana/example/set/union.cpp | 23 |
11 files changed, 241 insertions, 0 deletions
diff --git a/src/boost/libs/hana/example/set/comparable.cpp b/src/boost/libs/hana/example/set/comparable.cpp new file mode 100644 index 000000000..4bc2ecadb --- /dev/null +++ b/src/boost/libs/hana/example/set/comparable.cpp @@ -0,0 +1,26 @@ +// 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 <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/not_equal.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK( + hana::make_set(hana::int_c<0>, hana::type_c<char>, hana::int_c<1>) + == + hana::make_set(hana::int_c<1>, hana::int_c<0>, hana::type_c<char>) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::make_set(hana::int_c<0>, hana::type_c<char>) + != + hana::make_set(hana::int_c<1>) + ); +} diff --git a/src/boost/libs/hana/example/set/difference.cpp b/src/boost/libs/hana/example/set/difference.cpp new file mode 100644 index 000000000..e91a9222d --- /dev/null +++ b/src/boost/libs/hana/example/set/difference.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 <boost/hana/assert.hpp> +#include <boost/hana/difference.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +constexpr auto xs = hana::make_set(hana::int_c<1>, hana::int_c<2>, hana::type_c<int>, hana::int_c<3>); +constexpr auto ys = hana::make_set(hana::int_c<3>, hana::type_c<void>, hana::type_c<int>); + +BOOST_HANA_CONSTANT_CHECK(hana::difference(xs, ys) == hana::make_set(hana::int_c<1>, hana::int_c<2>)); +BOOST_HANA_CONSTANT_CHECK(hana::difference(ys, xs) == hana::make_set(hana::type_c<void>)); + +int main() { } diff --git a/src/boost/libs/hana/example/set/erase_key.cpp b/src/boost/libs/hana/example/set/erase_key.cpp new file mode 100644 index 000000000..d3bc3cd56 --- /dev/null +++ b/src/boost/libs/hana/example/set/erase_key.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 <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/erase_key.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +int main() { + constexpr auto xs = hana::make_set(hana::int_c<0>, hana::type_c<int>, hana::type_c<void>); + + BOOST_HANA_CONSTANT_CHECK(hana::erase_key(xs, hana::type_c<int>) == hana::make_set(hana::int_c<0>, hana::type_c<void>)); + BOOST_HANA_CONSTANT_CHECK(hana::erase_key(xs, hana::type_c<char>) == xs); +} diff --git a/src/boost/libs/hana/example/set/foldable.cpp b/src/boost/libs/hana/example/set/foldable.cpp new file mode 100644 index 000000000..0f17415eb --- /dev/null +++ b/src/boost/libs/hana/example/set/foldable.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 <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/maximum.hpp> +#include <boost/hana/minimum.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/sum.hpp> +namespace hana = boost::hana; + + +int main() { + constexpr auto xs = hana::make_set(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>); + static_assert(hana::minimum(xs) == hana::int_c<0>, ""); + static_assert(hana::maximum(xs) == hana::int_c<2>, ""); + static_assert(hana::sum<>(xs) == hana::int_c<3>, ""); +} diff --git a/src/boost/libs/hana/example/set/insert.cpp b/src/boost/libs/hana/example/set/insert.cpp new file mode 100644 index 000000000..47fffc760 --- /dev/null +++ b/src/boost/libs/hana/example/set/insert.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 <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/insert.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/string.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +int main() { + constexpr auto xs = hana::make_set(hana::int_c<0>, hana::type_c<int>); + BOOST_HANA_CONSTANT_CHECK( + hana::insert(xs, BOOST_HANA_STRING("abc")) == + hana::make_set(hana::int_c<0>, hana::type_c<int>, BOOST_HANA_STRING("abc")) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::insert(xs, hana::int_c<0>) == hana::make_set(hana::int_c<0>, hana::type_c<int>) + ); +} diff --git a/src/boost/libs/hana/example/set/intersection.cpp b/src/boost/libs/hana/example/set/intersection.cpp new file mode 100644 index 000000000..1d080432b --- /dev/null +++ b/src/boost/libs/hana/example/set/intersection.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 <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/intersection.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +constexpr auto xs = hana::make_set(hana::int_c<1>, hana::type_c<void>, hana::int_c<2>); +constexpr auto ys = hana::make_set(hana::int_c<2>, hana::type_c<int>, hana::int_c<3>); + +BOOST_HANA_CONSTANT_CHECK(hana::intersection(xs, ys) == hana::make_set(hana::int_c<2>)); + +int main() { } diff --git a/src/boost/libs/hana/example/set/make.cpp b/src/boost/libs/hana/example/set/make.cpp new file mode 100644 index 000000000..08f848340 --- /dev/null +++ b/src/boost/libs/hana/example/set/make.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 <boost/hana/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +constexpr auto xs = hana::make_set(hana::int_c<1>, hana::type_c<void>); +BOOST_HANA_CONSTANT_CHECK(xs == hana::make<hana::set_tag>(hana::int_c<1>, hana::type_c<void>)); + +int main() { } diff --git a/src/boost/libs/hana/example/set/searchable.cpp b/src/boost/libs/hana/example/set/searchable.cpp new file mode 100644 index 000000000..81fa26933 --- /dev/null +++ b/src/boost/libs/hana/example/set/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 <boost/hana/assert.hpp> +#include <boost/hana/at_key.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/find.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/optional.hpp> +#include <boost/hana/set.hpp> +namespace hana = boost::hana; + + +int main() { + constexpr auto xs = hana::make_set(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>); + BOOST_HANA_CONSTANT_CHECK(hana::find(xs, hana::int_c<0>) == hana::just(hana::int_c<0>)); + BOOST_HANA_CONSTANT_CHECK(hana::find(xs, hana::int_c<3>) == hana::nothing); + + // operator[] is equivalent to at_key + BOOST_HANA_CONSTANT_CHECK(xs[hana::int_c<2>] == hana::int_c<2>); + + // long_c<0> == int_<0>, and therefore int_<0> is found + BOOST_HANA_CONSTANT_CHECK(xs[hana::long_c<0>] == hana::int_c<0>); +} diff --git a/src/boost/libs/hana/example/set/symmetric_difference.cpp b/src/boost/libs/hana/example/set/symmetric_difference.cpp new file mode 100644 index 000000000..0e66e73e7 --- /dev/null +++ b/src/boost/libs/hana/example/set/symmetric_difference.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 <boost/hana/assert.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/symmetric_difference.hpp> + +namespace hana = boost::hana; + + +constexpr auto xs = hana::make_set(hana::int_c<1>, hana::int_c<2>, hana::type_c<int>, hana::int_c<3>); +constexpr auto ys = hana::make_set(hana::int_c<3>, hana::type_c<void>, hana::type_c<int>); + +BOOST_HANA_CONSTANT_CHECK( + hana::symmetric_difference(xs, ys) == hana::make_set(hana::int_c<1>, hana::int_c<2>, hana::type_c<void>) +); + +int main() { } diff --git a/src/boost/libs/hana/example/set/to.cpp b/src/boost/libs/hana/example/set/to.cpp new file mode 100644 index 000000000..59f0cb919 --- /dev/null +++ b/src/boost/libs/hana/example/set/to.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 <boost/hana/assert.hpp> +#include <boost/hana/core/to.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/tuple.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +int main() { + constexpr auto xs = hana::make_tuple( + hana::int_c<1>, + hana::int_c<3>, + hana::type_c<int>, + hana::long_c<1> + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::to<hana::set_tag>(xs) + == + hana::make_set(hana::int_c<1>, hana::int_c<3>, hana::type_c<int>) + ); +} diff --git a/src/boost/libs/hana/example/set/union.cpp b/src/boost/libs/hana/example/set/union.cpp new file mode 100644 index 000000000..b52d1d4ac --- /dev/null +++ b/src/boost/libs/hana/example/set/union.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 <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/string.hpp> +#include <boost/hana/type.hpp> +#include <boost/hana/union.hpp> +namespace hana = boost::hana; +using namespace hana::literals; + + +constexpr auto xs = hana::make_set(hana::int_c<1>, hana::type_c<void>, hana::int_c<2>); +constexpr auto ys = hana::make_set(hana::int_c<2>, hana::type_c<int>, hana::int_c<3>); + +BOOST_HANA_CONSTANT_CHECK(hana::union_(xs, ys) == hana::make_set( + hana::int_c<1>, hana::int_c<2>, hana::int_c<3>, hana::type_c<void>, hana::type_c<int> +)); + +int main() { } |