]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/optional/sfinae.cpp
1 // Copyright Louis Dionne 2013-2017
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/chain.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/optional.hpp>
10 #include <laws/base.hpp>
11 #include <support/tracked.hpp>
12 namespace hana
= boost::hana
;
13 using hana::test::ct_eq
;
19 hana::test::_injection
<0> f
{};
21 BOOST_HANA_CONSTANT_CHECK(hana::equal(
26 BOOST_HANA_CONSTANT_CHECK(hana::equal(
27 hana::sfinae(f
)(ct_eq
<0>{}),
28 hana::just(f(ct_eq
<0>{}))
31 BOOST_HANA_CONSTANT_CHECK(hana::equal(
32 hana::sfinae(f
)(ct_eq
<0>{}, ct_eq
<1>{}),
33 hana::just(f(ct_eq
<0>{}, ct_eq
<1>{}))
36 BOOST_HANA_CONSTANT_CHECK(hana::equal(
37 hana::sfinae(undefined
{})(),
41 BOOST_HANA_CONSTANT_CHECK(hana::equal(
42 hana::sfinae(undefined
{})(ct_eq
<0>{}),
46 BOOST_HANA_CONSTANT_CHECK(hana::equal(
47 hana::sfinae(undefined
{})(ct_eq
<0>{}, ct_eq
<1>{}),
51 auto incr
= hana::sfinae([](auto x
) -> decltype(x
+ 1) {
55 BOOST_HANA_RUNTIME_CHECK(hana::equal(
59 BOOST_HANA_CONSTANT_CHECK(hana::equal(
63 BOOST_HANA_RUNTIME_CHECK(hana::equal(
64 hana::chain(hana::just(1), incr
),
68 // using `sfinae` with a non-pod argument used to fail
69 hana::sfinae(undefined
{})(Tracked
{1});
70 hana::sfinae([t
= Tracked
{1}](auto) { return 1; })(Tracked
{1});