]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/test/if_/non_copyable.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / if_ / non_copyable.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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)
4
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>
10namespace hana = boost::hana;
11
12
13// This test makes sure that if_ can be used with non-copyable branches.
14
15template <bool Value>
16struct Boolean { };
17
18namespace boost { namespace hana {
19 template <bool Value>
20 struct while_impl<Boolean<Value>> {
21 // Not implemented
22 };
23
24 template <bool Value>
25 struct not_impl<Boolean<Value>> {
26 // Not implemented
27 };
28
29 template <bool 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));
35 }
36 };
37}}
38
39template <int v>
40struct NonCopyable {
41 static constexpr int value = v;
42 NonCopyable() = default;
43 NonCopyable(NonCopyable const&) = delete;
44 NonCopyable(NonCopyable&&) = default;
45
46 NonCopyable& operator=(NonCopyable const&) = delete;
47 NonCopyable& operator=(NonCopyable&&) = default;
48};
49
50static_assert(hana::if_(Boolean<true>{}, NonCopyable<3>{}, NonCopyable<4>{}).value == 3, "");
51static_assert(hana::if_(Boolean<false>{}, NonCopyable<3>{}, NonCopyable<4>{}).value == 4, "");
52
53int main() { }