]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/include/boost/hana/and.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / and.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Defines `boost::hana::and_`.
4
5@copyright Louis Dionne 2013-2016
6Distributed 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_AND_HPP
11#define BOOST_HANA_AND_HPP
12
13#include <boost/hana/fwd/and.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
22BOOST_HANA_NAMESPACE_BEGIN
23 //! @cond
24 template <typename X, typename Y>
25 constexpr decltype(auto) and_t::operator()(X&& x, Y&& y) const {
26 using Bool = typename hana::tag_of<X>::type;
27 using And = BOOST_HANA_DISPATCH_IF(and_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::and_(x, y) requires 'x' to be a Logical");
34 #endif
35
36 return And::apply(static_cast<X&&>(x), static_cast<Y&&>(y));
37 }
38
39 template <typename X, typename ...Y>
40 constexpr decltype(auto) and_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 and_impl<L, when<condition>> : default_ {
51 template <typename X, typename Y>
52 static constexpr decltype(auto) apply(X&& x, Y&& y) {
53 return hana::if_(x, static_cast<Y&&>(y), x);
54 }
55 };
56BOOST_HANA_NAMESPACE_END
57
58#endif // !BOOST_HANA_AND_HPP