]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/if_/non_copyable.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/bool.hpp>
6 #include <boost/hana/eval_if.hpp>
7 #include <boost/hana/fwd/not.hpp>
8 #include <boost/hana/fwd/while.hpp>
9 #include <boost/hana/if.hpp>
10 namespace hana
= boost::hana
;
13 // This test makes sure that if_ can be used with non-copyable branches.
18 namespace boost
{ namespace hana
{
20 struct while_impl
<Boolean
<Value
>> {
25 struct not_impl
<Boolean
<Value
>> {
30 struct eval_if_impl
<Boolean
<Value
>> {
31 template <typename Cond
, typename Then
, typename Else
>
32 static constexpr decltype(auto) apply(Cond
const&, Then
&& t
, Else
&& e
) {
33 return hana::eval_if(hana::bool_c
<Value
>, static_cast<Then
&&>(t
),
34 static_cast<Else
&&>(e
));
41 static constexpr int value
= v
;
42 NonCopyable() = default;
43 NonCopyable(NonCopyable
const&) = delete;
44 NonCopyable(NonCopyable
&&) = default;
46 NonCopyable
& operator=(NonCopyable
const&) = delete;
47 NonCopyable
& operator=(NonCopyable
&&) = default;
50 static_assert(hana::if_(Boolean
<true>{}, NonCopyable
<3>{}, NonCopyable
<4>{}).value
== 3, "");
51 static_assert(hana::if_(Boolean
<false>{}, NonCopyable
<3>{}, NonCopyable
<4>{}).value
== 4, "");