diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/hana/test/detail/variadic/foldr1.cpp | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/hana/test/detail/variadic/foldr1.cpp')
-rw-r--r-- | src/boost/libs/hana/test/detail/variadic/foldr1.cpp | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/detail/variadic/foldr1.cpp b/src/boost/libs/hana/test/detail/variadic/foldr1.cpp new file mode 100644 index 00000000..1d7d91ed --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/foldr1.cpp @@ -0,0 +1,207 @@ +// 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/detail/variadic/foldr1.hpp> + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/value.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; + + +struct undefined { }; + +template <int i> +using x = hana::test::ct_eq<i>; + +// We do not use test::_injection here because comparing the result would +// blow away the template recursion limit. +struct f_t { + template <typename X, typename Y> + constexpr auto operator()(X const&, Y const&) { + return x<hana::value<X>() - hana::value<Y>()>{}; + } +}; + +int main() { + using hana::detail::variadic::foldr1; + f_t f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(undefined{}, x<0>{}), + x<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}), + f(x<0>{}, x<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}), + f(x<0>{}, f(x<1>{}, x<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, x<3>{}))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, x<4>{})))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, x<5>{}))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, x<6>{})))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, x<7>{} + ))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, x<8>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, x<8>{} + )))))))) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, x<13>{} + )))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, x<14>{} + ))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, x<15>{} + )))))))))))))) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, x<27>{} + )))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, x<28>{} + ))))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + x<29>{} + )))))))))))))))))))))))))))) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + f(x<29>{}, f(x<30>{}, f(x<31>{}, f(x<32>{}, f(x<33>{}, f(x<34>{}, f(x<35>{}, + f(x<36>{}, f(x<37>{}, f(x<38>{}, f(x<39>{}, f(x<40>{}, f(x<41>{}, f(x<42>{}, + f(x<43>{}, f(x<44>{}, f(x<45>{}, f(x<46>{}, f(x<47>{}, f(x<48>{}, f(x<49>{}, + f(x<50>{}, f(x<51>{}, f(x<52>{}, f(x<53>{}, f(x<54>{}, x<55>{} + )))))))))))))))))))))))))))))))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}, x<56>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + f(x<29>{}, f(x<30>{}, f(x<31>{}, f(x<32>{}, f(x<33>{}, f(x<34>{}, f(x<35>{}, + f(x<36>{}, f(x<37>{}, f(x<38>{}, f(x<39>{}, f(x<40>{}, f(x<41>{}, f(x<42>{}, + f(x<43>{}, f(x<44>{}, f(x<45>{}, f(x<46>{}, f(x<47>{}, f(x<48>{}, f(x<49>{}, + f(x<50>{}, f(x<51>{}, f(x<52>{}, f(x<53>{}, f(x<54>{}, f(x<55>{}, x<56>{} + ))))))))))))))))))))))))))))))))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}, x<56>{}, + x<57>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + f(x<29>{}, f(x<30>{}, f(x<31>{}, f(x<32>{}, f(x<33>{}, f(x<34>{}, f(x<35>{}, + f(x<36>{}, f(x<37>{}, f(x<38>{}, f(x<39>{}, f(x<40>{}, f(x<41>{}, f(x<42>{}, + f(x<43>{}, f(x<44>{}, f(x<45>{}, f(x<46>{}, f(x<47>{}, f(x<48>{}, f(x<49>{}, + f(x<50>{}, f(x<51>{}, f(x<52>{}, f(x<53>{}, f(x<54>{}, f(x<55>{}, f(x<56>{}, + x<57>{} + )))))))))))))))))))))))))))))))))))))))))))))))))))))))) + )); +} |