Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:01

0001 /*!
0002 @file
0003 Defines `boost::hana::and_`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
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     //! @cond
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     //! @endcond
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 }} // end namespace boost::hana
0057 
0058 #endif // !BOOST_HANA_AND_HPP