2
0
mirror of https://github.com/boostorg/hana.git synced 2026-02-02 08:52:11 +00:00
Files
hana/example/type/trait.cpp

31 lines
949 B
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/detail/constexpr.hpp>
#include <boost/hana/ext/std/integral_constant.hpp>
#include <boost/hana/integral.hpp>
#include <boost/hana/type.hpp>
#include <type_traits>
using namespace boost::hana;
int main() {
//! [liftable]
BOOST_HANA_CONSTANT_CHECK(trait<std::is_integral>(type<int>));
BOOST_HANA_CONSTANT_CHECK(not_(trait<std::is_integral>(type<float>)));
//! [liftable]
//! [nonliftable]
BOOST_HANA_CONSTEXPR_LAMBDA auto extent = [](auto t, auto n) {
return std::extent<typename decltype(t)::type, n()>{};
};
BOOST_HANA_CONSTANT_CHECK(extent(type<char>, int_<1>) == int_<0>);
BOOST_HANA_CONSTANT_CHECK(extent(type<char[1][2]>, int_<1>) == int_<2>);
//! [nonliftable]
}