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/range | |
parent | Initial commit. (diff) | |
download | ceph-upstream/16.2.11+ds.tar.xz ceph-upstream/16.2.11+ds.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/range')
-rw-r--r-- | src/boost/libs/hana/example/range/comparable.cpp | 20 | ||||
-rw-r--r-- | src/boost/libs/hana/example/range/foldable.cpp | 25 | ||||
-rw-r--r-- | src/boost/libs/hana/example/range/iterable.cpp | 24 | ||||
-rw-r--r-- | src/boost/libs/hana/example/range/make.cpp | 19 | ||||
-rw-r--r-- | src/boost/libs/hana/example/range/range_c.cpp | 19 | ||||
-rw-r--r-- | src/boost/libs/hana/example/range/searchable.cpp | 17 |
6 files changed, 124 insertions, 0 deletions
diff --git a/src/boost/libs/hana/example/range/comparable.cpp b/src/boost/libs/hana/example/range/comparable.cpp new file mode 100644 index 000000000..a27014cc4 --- /dev/null +++ b/src/boost/libs/hana/example/range/comparable.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/not_equal.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +// empty ranges are equal +BOOST_HANA_CONSTANT_CHECK(hana::make_range(hana::int_c<6>, hana::int_c<6>) == hana::make_range(hana::int_c<0>, hana::int_c<0>)); + +// otherwise, ranges are equal if and only if they span the same interval +BOOST_HANA_CONSTANT_CHECK(hana::make_range(hana::int_c<2>, hana::int_c<5>) == hana::make_range(hana::int_c<2>, hana::int_c<5>)); +BOOST_HANA_CONSTANT_CHECK(hana::make_range(hana::int_c<0>, hana::int_c<3>) != hana::make_range(hana::int_c<-1>, hana::int_c<3>)); + +int main() { } diff --git a/src/boost/libs/hana/example/range/foldable.cpp b/src/boost/libs/hana/example/range/foldable.cpp new file mode 100644 index 000000000..e294b543f --- /dev/null +++ b/src/boost/libs/hana/example/range/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 <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/fold_left.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/plus.hpp> +#include <boost/hana/range.hpp> +#include <boost/hana/tuple.hpp> +#include <boost/hana/unpack.hpp> +namespace hana = boost::hana; + + +BOOST_HANA_CONSTANT_CHECK( + hana::fold_left(hana::make_range(hana::int_c<0>, hana::int_c<4>), hana::int_c<0>, hana::plus) == hana::int_c<6> +); + +BOOST_HANA_CONSTANT_CHECK( + hana::unpack(hana::make_range(hana::int_c<-2>, hana::int_c<2>), hana::make_tuple) == + hana::make_tuple(hana::int_c<-2>, hana::int_c<-1>, hana::int_c<0>, hana::int_c<1>) +); + +int main() { } diff --git a/src/boost/libs/hana/example/range/iterable.cpp b/src/boost/libs/hana/example/range/iterable.cpp new file mode 100644 index 000000000..f696ebc61 --- /dev/null +++ b/src/boost/libs/hana/example/range/iterable.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 <boost/hana/assert.hpp> +#include <boost/hana/back.hpp> +#include <boost/hana/drop_front.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/front.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/is_empty.hpp> +#include <boost/hana/not.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +constexpr auto r = hana::make_range(hana::int_c<0>, hana::int_c<1000>); +BOOST_HANA_CONSTANT_CHECK(hana::front(r) == hana::int_c<0>); +BOOST_HANA_CONSTANT_CHECK(hana::back(r) == hana::int_c<999>); +BOOST_HANA_CONSTANT_CHECK(hana::drop_front(r) == hana::make_range(hana::int_c<1>, hana::int_c<1000>)); +BOOST_HANA_CONSTANT_CHECK(!hana::is_empty(r)); +BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::make_range(hana::int_c<3>, hana::int_c<3>))); + +int main() { } diff --git a/src/boost/libs/hana/example/range/make.cpp b/src/boost/libs/hana/example/range/make.cpp new file mode 100644 index 000000000..0c151054f --- /dev/null +++ b/src/boost/libs/hana/example/range/make.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/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +constexpr auto irange = hana::make<hana::range_tag>(hana::int_c<0>, hana::int_c<10>); // [0, 10) int +BOOST_HANA_CONSTANT_CHECK(irange == hana::make<hana::range_tag>(hana::int_c<0>, hana::int_c<10>)); + +constexpr auto lrange = hana::make<hana::range_tag>(hana::int_c<0>, hana::long_c<10>); // [0, 10) long +BOOST_HANA_CONSTANT_CHECK(lrange == hana::make<hana::range_tag>(hana::long_c<0>, hana::long_c<10>)); + +int main() { } diff --git a/src/boost/libs/hana/example/range/range_c.cpp b/src/boost/libs/hana/example/range/range_c.cpp new file mode 100644 index 000000000..9b7da7aee --- /dev/null +++ b/src/boost/libs/hana/example/range/range_c.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/back.hpp> +#include <boost/hana/drop_front.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/front.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +BOOST_HANA_CONSTANT_CHECK(hana::front(hana::range_c<int, 0, 5>) == hana::int_c<0>); +BOOST_HANA_CONSTANT_CHECK(hana::back(hana::range_c<unsigned long, 0, 5>) == hana::ulong_c<4>); +BOOST_HANA_CONSTANT_CHECK(hana::drop_front(hana::range_c<int, 0, 5>) == hana::make_range(hana::int_c<1>, hana::int_c<5>)); + +int main() { } diff --git a/src/boost/libs/hana/example/range/searchable.cpp b/src/boost/libs/hana/example/range/searchable.cpp new file mode 100644 index 000000000..4ffb5205d --- /dev/null +++ b/src/boost/libs/hana/example/range/searchable.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/equal.hpp> +#include <boost/hana/find.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/optional.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +BOOST_HANA_CONSTANT_CHECK(hana::find(hana::make_range(hana::int_c<1>, hana::int_c<25>), hana::int_c<10>) == hana::just(hana::int_c<10>)); +BOOST_HANA_CONSTANT_CHECK(hana::find(hana::make_range(hana::int_c<1>, hana::int_c<25>), hana::int_c<200>) == hana::nothing); + +int main() { } |