]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/or.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / or.hpp
1 /*!
2 @file
3 Defines `boost::hana::or_`.
4
5 @copyright Louis Dionne 2013-2016
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8 */
9
10 #ifndef BOOST_HANA_OR_HPP
11 #define BOOST_HANA_OR_HPP
12
13 #include <boost/hana/fwd/or.hpp>
14
15 #include <boost/hana/concept/logical.hpp>
16 #include <boost/hana/config.hpp>
17 #include <boost/hana/core/dispatch.hpp>
18 #include <boost/hana/detail/variadic/foldl1.hpp>
19 #include <boost/hana/if.hpp>
20
21
22 BOOST_HANA_NAMESPACE_BEGIN
23 //! @cond
24 template <typename X, typename Y>
25 constexpr decltype(auto) or_t::operator()(X&& x, Y&& y) const {
26 using Bool = typename hana::tag_of<X>::type;
27 using Or = BOOST_HANA_DISPATCH_IF(or_impl<Bool>,
28 hana::Logical<Bool>::value
29 );
30
31 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
32 static_assert(hana::Logical<Bool>::value,
33 "hana::or_(x, y) requires 'x' to be a Logical");
34 #endif
35
36 return Or::apply(static_cast<X&&>(x), static_cast<Y&&>(y));
37 }
38
39 template <typename X, typename ...Y>
40 constexpr decltype(auto) or_t::operator()(X&& x, Y&& ...y) const {
41 return detail::variadic::foldl1(
42 *this,
43 static_cast<X&&>(x),
44 static_cast<Y&&>(y)...
45 );
46 }
47 //! @endcond
48
49 template <typename L, bool condition>
50 struct or_impl<L, when<condition>> : hana::default_ {
51 template <typename X, typename Y>
52 static constexpr decltype(auto) apply(X&& x, Y&& y) {
53 //! @todo How to forward `x` here? Since the arguments to `if_`
54 //! can be evaluated in any order, we have to be careful not to
55 //! use `x` in a moved-from state.
56 return hana::if_(x, x, static_cast<Y&&>(y));
57 }
58 };
59 BOOST_HANA_NAMESPACE_END
60
61 #endif // !BOOST_HANA_OR_HPP