File indexing completed on 2025-01-18 09:38:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_HANA_OR_HPP
0011 #define BOOST_HANA_OR_HPP
0012
0013 #include <boost/hana/fwd/or.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) or_t::operator()(X&& x, Y&& y) const {
0026 using Bool = typename hana::tag_of<X>::type;
0027 using Or = BOOST_HANA_DISPATCH_IF(or_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::or_(x, y) requires 'x' to be a Logical");
0034 #endif
0035
0036 return Or::apply(static_cast<X&&>(x), static_cast<Y&&>(y));
0037 }
0038
0039 template <typename X, typename ...Y>
0040 constexpr decltype(auto) or_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 or_impl<L, when<condition>> : hana::default_ {
0051 template <typename X, typename Y>
0052 static constexpr decltype(auto) apply(X&& x, Y&& y) {
0053
0054
0055
0056 return hana::if_(x, x, static_cast<Y&&>(y));
0057 }
0058 };
0059 }}
0060
0061 #endif