本文整理匯總了C++中BOOST_HANA_CONSTANT_CHECK函數的典型用法代碼示例。如果您正苦於以下問題:C++ BOOST_HANA_CONSTANT_CHECK函數的具體用法?C++ BOOST_HANA_CONSTANT_CHECK怎麽用?C++ BOOST_HANA_CONSTANT_CHECK使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BOOST_HANA_CONSTANT_CHECK函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: main
int main() {
// Interoperation with hana::integral_constant
BOOST_HANA_CONSTANT_CHECK(mpl::integral_c<int, 1>{} == hana::int_c<1>);
BOOST_HANA_CONSTANT_CHECK(mpl::integral_c<int, 1>{} == hana::long_c<1>);
BOOST_HANA_CONSTANT_CHECK(mpl::integral_c<int, 2>{} != hana::int_c<3>);
}
示例2: main
int main() {
auto container = ::seq;
{
auto storage = container();
auto transformed = hana::experimental::transformed(storage, undefined<99>{});
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::length(transformed),
hana::size_c<0>
));
}{
auto storage = container(undefined<0>{});
auto transformed = hana::experimental::transformed(storage, undefined<99>{});
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::length(transformed),
hana::size_c<1>
));
}{
auto storage = container(undefined<0>{}, undefined<1>{});
auto transformed = hana::experimental::transformed(storage, undefined<99>{});
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::length(transformed),
hana::size_c<2>
));
}{
auto storage = container(undefined<0>{}, undefined<1>{}, undefined<2>{});
auto transformed = hana::experimental::transformed(storage, undefined<99>{});
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::length(transformed),
hana::size_c<3>
));
}
}
示例3: main
int main() {
BOOST_HANA_CONSTANT_CHECK(hana::length(hana::make_tuple()) == hana::size_c<0>);
BOOST_HANA_CONSTANT_CHECK(hana::length(hana::make_tuple(1, '2', 3.0)) == hana::size_c<3>);
BOOST_HANA_CONSTANT_CHECK(hana::length(hana::nothing) == hana::size_c<0>);
BOOST_HANA_CONSTANT_CHECK(hana::length(hana::just('x')) == hana::size_c<1>);
}
示例4: main
int main() {
// Conversion from any `Foldable` containing `type`s
auto foldable = ::seq;
auto to_list = hana::to<hana::ext::boost::mpl::list_tag>;
BOOST_HANA_CONSTANT_CHECK(hana::equal(
to_list(foldable()),
mpl::list<>{}
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
to_list(foldable(hana::type_c<t1>)),
mpl::list<t1>{}
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
to_list(foldable(hana::type_c<t1>, hana::type_c<t2>)),
mpl::list<t1, t2>{}
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
to_list(foldable(hana::type_c<t1>, hana::type_c<t2>, hana::type_c<t3>)),
mpl::list<t1, t2, t3>{}
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
to_list(foldable(hana::type_c<t1>, hana::type_c<t2>, hana::type_c<t3>, hana::type_c<t4>)),
mpl::list<t1, t2, t3, t4>{}
));
}
示例5: main
int main() {
auto container = ::seq;
{
auto storage1 = container();
auto storage2 = container();
auto joined = hana::experimental::joined(storage1, storage2);
BOOST_HANA_CONSTANT_CHECK(hana::is_empty(joined));
}
{
auto storage1 = container(undefined<0>{});
auto storage2 = container();
auto joined = hana::experimental::joined(storage1, storage2);
BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined)));
}
{
auto storage1 = container(undefined<0>{});
auto storage2 = container(undefined<1>{});
auto joined = hana::experimental::joined(storage1, storage2);
BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined)));
}
{
auto storage1 = container();
auto storage2 = container(undefined<0>{});
auto joined = hana::experimental::joined(storage1, storage2);
BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined)));
}
}
示例6: main
int main() {
// works with elements whose `less` does not return a Constant
{
constexpr auto xs = hana::make_tuple(1, 2, 3, 4);
constexpr auto ys = hana::make_tuple(1, 6, 3, 4);
static_assert(hana::lexicographical_compare(xs, ys), "");
}
// and with those that do
{
auto xs = hana::make_tuple(hana::int_<1>, hana::int_<2>, hana::int_<3>);
auto ys = hana::make_tuple(hana::int_<1>, hana::int_<5>, hana::int_<3>);
BOOST_HANA_CONSTANT_CHECK(hana::lexicographical_compare(xs, ys));
}
// it also accepts a custom predicate
{
auto xs = hana::make_tuple(hana::type<int>, hana::type<char>, hana::type<void*>);
auto ys = hana::make_tuple(hana::type<int>, hana::type<long>, hana::type<void*>);
BOOST_HANA_CONSTANT_CHECK(
hana::lexicographical_compare(xs, ys, [](auto t, auto u) {
return hana::sizeof_(t) < hana::sizeof_(u);
})
);
}
}
示例7: main
int main() {
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::make<hana::type_tag>(T{}),
hana::decltype_(T{})
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::make<hana::type_tag>(hana::type_c<T>),
hana::decltype_(hana::type_c<T>)
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::make_type(T{}),
hana::make<hana::type_tag>(T{})
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::make_type(hana::type_c<T>),
hana::make<hana::type_tag>(hana::type_c<T>)
));
// make sure we don't read from non-constexpr variables
{
auto t = hana::type_c<T>;
auto x = 1;
constexpr auto r1 = hana::make<hana::type_tag>(t); (void)r1;
constexpr auto r2 = hana::make<hana::type_tag>(x); (void)r2;
}
}
示例8: main
int main() {
auto deref = [](auto x) { return *x; };
auto deref3 = hana::compose(deref, deref, deref);
BOOST_HANA_CONSTANT_CHECK(hana::equal(
*hana::type_c<char*>,
hana::type_c<char&>
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
deref(hana::type_c<int*>),
hana::type_c<int&>
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
deref3(hana::type_c<int***>),
hana::type_c<int&>
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::type_c<int> + hana::type_c<float>,
hana::type_c<float>
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
++hana::type_c<int&>,
hana::type_c<int&>
));
}
示例9: main
int main() {
hana::test::_injection<0> f{};
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<0>), f),
f()
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<1>), f),
f(hana::int_c<0>)
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<2>), f),
f(hana::int_c<0>, hana::int_c<1>)
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<3>), f),
f(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>)
));
// Previously, we would only unpack with `std::size_t`s. Make
// sure this does not happen.
hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<1>), [](auto x) {
using T = hana::tag_of_t<decltype(x)>;
static_assert(std::is_same<typename T::value_type, int>{}, "");
});
}
示例10: main
int main() {
BOOST_HANA_CONSTANT_CHECK(hana::char_c<'c'> ^hana::in^ BOOST_HANA_STRING("abcde"));
BOOST_HANA_CONSTANT_CHECK(!(hana::char_c<'z'> ^hana::in^ BOOST_HANA_STRING("abcde")));
BOOST_HANA_CONSTANT_CHECK(
hana::find(BOOST_HANA_STRING("abcxefg"), hana::char_c<'x'>) == hana::just(hana::char_c<'x'>)
);
}
示例11: main
int main() {
BOOST_HANA_CONSTANT_CHECK(
hana::to<hana::tuple_tag>(hana::tuple_c<int, 0, 1, 2>)
==
hana::make_tuple(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>)
);
BOOST_HANA_CONSTANT_CHECK(hana::front(hana::tuple_c<int, 0, 1, 2>) == hana::int_c<0>);
}
示例12: main
int main() {
constexpr auto ints = hana::tuple_c<int, 1, 2, 3, 2, 2, 4, 2>;
BOOST_HANA_CONSTANT_CHECK(hana::count(ints, hana::int_<2>) == hana::size_t<4>);
static_assert(hana::count(ints, 2) == 4, "");
constexpr auto types = hana::tuple_t<int, char, long, short, char, double>;
BOOST_HANA_CONSTANT_CHECK(hana::count(types, hana::type<char>) == hana::size_t<2>);
}
示例13: main
int main() {
constexpr auto x = hana::make<hana::optional_tag>();
BOOST_HANA_CONSTANT_CHECK(x == hana::make_optional());
BOOST_HANA_CONSTANT_CHECK(hana::is_nothing(x));
constexpr auto just_x = hana::make<hana::optional_tag>('x');
static_assert(just_x == hana::make_optional('x'), "");
BOOST_HANA_CONSTANT_CHECK(hana::is_just(just_x));
}
示例14: main
int main() {
static_assert(hana::to<hana::tuple_tag>(hana::just(1)) == hana::make_tuple(1), "");
BOOST_HANA_CONSTANT_CHECK(hana::to<hana::tuple_tag>(hana::nothing) == hana::make_tuple());
BOOST_HANA_CONSTANT_CHECK(
hana::to<hana::tuple_tag>(hana::make_range(hana::int_c<3>, hana::int_c<6>))
==
hana::tuple_c<int, 3, 4, 5>
);
}
示例15: main
int main() {
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::at_key(hana::make_map(p<0, 0>()), key<0>()),
val<0>()
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::at_key(hana::make_map(p<0, 0>(), p<1,1>()), key<0>()),
val<0>()
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::at_key(hana::make_map(p<0, 0>(), p<1,1>()), key<1>()),
val<1>()
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::at_key(hana::make_map(p<0, 0>(), p<1,1>(), p<2,2>()), key<0>()),
val<0>()
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::at_key(hana::make_map(p<0, 0>(), p<1,1>(), p<2,2>()), key<1>()),
val<1>()
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::at_key(hana::make_map(p<0, 0>(), p<1,1>(), p<2,2>()), key<2>()),
val<2>()
));
// check operators
auto m = hana::make_map(p<2, 2>(), p<1, 1>());
auto const const_m = hana::make_map(p<2, 2>(), p<1, 1>());
BOOST_HANA_CONSTANT_CHECK(hana::equal(m[key<1>()], val<1>()));
BOOST_HANA_CONSTANT_CHECK(hana::equal(const_m[key<1>()], val<1>()));
BOOST_HANA_CONSTANT_CHECK(hana::equal(std::move(m)[key<1>()], val<1>()));
}