File indexing completed on 2025-01-18 09:38:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_HANA_AND_HPP
0011 #define BOOST_HANA_AND_HPP
0012
0013 #include <boost/hana/fwd/and.hpp>
0014
0015 #include <boost/hana/concept/logical.hpp>
0016 #include <boost/hana/config.hpp>
0017 #include <boost/hana/core/dispatch.hpp>
0018 #include <boost/hana/detail/variadic/foldl1.hpp>
0019 #include <boost/hana/if.hpp>
0020
0021
0022 namespace boost { namespace hana {
0023
0024 template <typename X, typename Y>
0025 constexpr decltype(auto) and_t::operator()(X&& x, Y&& y) const {
0026 using Bool = typename hana::tag_of<X>::type;
0027 using And = BOOST_HANA_DISPATCH_IF(and_impl<Bool>,
0028 hana::Logical<Bool>::value
0029 );
0030
0031 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0032 static_assert(hana::Logical<Bool>::value,
0033 "hana::and_(x, y) requires 'x' to be a Logical");
0034 #endif
0035
0036 return And::apply(static_cast<X&&>(x), static_cast<Y&&>(y));
0037 }
0038
0039 template <typename X, typename ...Y>
0040 constexpr decltype(auto) and_t::operator()(X&& x, Y&& ...y) const {
0041 return detail::variadic::foldl1(
0042 *this,
0043 static_cast<X&&>(x),
0044 static_cast<Y&&>(y)...
0045 );
0046 }
0047
0048
0049 template <typename L, bool condition>
0050 struct and_impl<L, when<condition>> : default_ {
0051 template <typename X, typename Y>
0052 static constexpr decltype(auto) apply(X&& x, Y&& y) {
0053 return hana::if_(x, static_cast<Y&&>(y), x);
0054 }
0055 };
0056 }}
0057
0058 #endif