mirror of
https://github.com/boostorg/hana.git
synced 2026-01-22 17:22:30 +00:00
53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
/*
|
|
@copyright Louis Dionne 2014
|
|
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/bool.hpp>
|
|
#include <boost/hana/comparable.hpp>
|
|
#include <boost/hana/core/models.hpp>
|
|
#include <boost/hana/detail/constexpr.hpp>
|
|
#include <boost/hana/ext/std/tuple.hpp>
|
|
#include <boost/hana/integral_constant.hpp>
|
|
#include <boost/hana/iterable.hpp>
|
|
#include <boost/hana/logical.hpp>
|
|
#include <boost/hana/maybe.hpp>
|
|
#include <boost/hana/monad.hpp>
|
|
#include <boost/hana/range.hpp>
|
|
#include <boost/hana/tuple.hpp>
|
|
|
|
#include <tuple>
|
|
using namespace boost::hana;
|
|
|
|
|
|
int main() {
|
|
//! [standard]
|
|
BOOST_HANA_CONSTANT_CHECK( is<Foldable, Maybe>);
|
|
BOOST_HANA_CONSTANT_CHECK(!is<Logical, Maybe>);
|
|
BOOST_HANA_CONSTANT_CHECK(!is<Foldable, int>);
|
|
BOOST_HANA_CONSTANT_CHECK( is<Comparable, int>);
|
|
//! [standard]
|
|
|
|
//! [alternate]
|
|
constexpr auto row = tuple;
|
|
BOOST_HANA_CONSTEXPR_LAMBDA auto check_table = [](auto ...headers) {
|
|
return [=](auto ...rows) {
|
|
auto row_is_correct = [=](auto row) {
|
|
return tuple(headers(head(row))...) == tail(row);
|
|
};
|
|
BOOST_HANA_CONSTANT_CHECK(all(tuple(rows...), row_is_correct));
|
|
};
|
|
};
|
|
|
|
check_table( is<Logical>, is<Iterable>, is_a<Monad> )(
|
|
row(just(1), false_, false_, true_ ),
|
|
row(tuple(1, '2', 3.3), false_, true_, true_ ),
|
|
row(std::make_tuple("abc", 'd'), false_, true_, true_ ),
|
|
row(long_<12>, true_, false_, false_ ),
|
|
row(range(int_<-4>, int_<15>), false_, true_, false_ )
|
|
);
|
|
//! [alternate]
|
|
}
|