Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:52:46

0001 /*!
0002 @file
0003 Defines `BOOST_HANA_DISPATCH_IF`.
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_DETAIL_DISPATCH_IF_HPP
0011 #define BOOST_HANA_DETAIL_DISPATCH_IF_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 
0015 #include <type_traits>
0016 
0017 
0018 namespace boost { namespace hana {
0019     struct deleted_implementation {
0020         template <typename ...T>
0021         static constexpr auto apply(T&& ...) = delete;
0022     };
0023 
0024     //! @ingroup group-details
0025     //! Dispatch to the given implementation method only when a condition is
0026     //! satisfied.
0027     //!
0028     //! If the condition is satisfied, this macro is equivalent to the type
0029     //! `IMPL`. Otherwise, it is equivalent to a type with a deleted static
0030     //! function named `apply`. When a tag-dispatching error happens, the
0031     //! condition should be false and the deleted static function `apply`
0032     //! will prevent the compiler from generating too much garbage.
0033     //!
0034     //! @note
0035     //! When `BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS` is defined, the
0036     //! condition is always ignored and this macro expands to the
0037     //! implementation only.
0038     //!
0039     //! @remark
0040     //! This must be implemented as a macro, because we don't want the
0041     //! condition to be evaluated at all when
0042     //! `BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS` is defined.
0043 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0044     #define BOOST_HANA_DISPATCH_IF(IMPL, ...)                               \
0045         ::std::conditional_t<                                               \
0046             (__VA_ARGS__),                                                  \
0047             IMPL,                                                           \
0048             ::boost::hana::deleted_implementation                           \
0049         >                                                                   \
0050     /**/
0051 #else
0052     #define BOOST_HANA_DISPATCH_IF(IMPL, ...) IMPL
0053 #endif
0054 }} // end namespace boost::hana
0055 
0056 #endif // !BOOST_HANA_DETAIL_DISPATCH_IF_HPP