3 Defines `BOOST_HANA_DISPATCH_IF`.
5 @copyright Louis Dionne 2013-2017
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_HANA_DETAIL_DISPATCH_IF_HPP
11 #define BOOST_HANA_DETAIL_DISPATCH_IF_HPP
13 #include <boost/hana/config.hpp>
15 #include <type_traits>
18 BOOST_HANA_NAMESPACE_BEGIN
19 struct deleted_implementation {
20 template <typename ...T>
21 static constexpr auto apply(T&& ...) = delete;
24 //! @ingroup group-details
25 //! Dispatch to the given implementation method only when a condition is
28 //! If the condition is satisfied, this macro is equivalent to the type
29 //! `IMPL`. Otherwise, it is equivalent to a type with a deleted static
30 //! function named `apply`. When a tag-dispatching error happens, the
31 //! condition should be false and the deleted static function `apply`
32 //! will prevent the compiler from generating too much garbage.
35 //! When `BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS` is defined, the
36 //! condition is always ignored and this macro expands to the
37 //! implementation only.
40 //! This must be implemented as a macro, because we don't want the
41 //! condition to be evaluated at all when
42 //! `BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS` is defined.
43 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
44 #define BOOST_HANA_DISPATCH_IF(IMPL, ...) \
45 ::std::conditional_t< \
48 ::boost::hana::deleted_implementation \
52 #define BOOST_HANA_DISPATCH_IF(IMPL, ...) IMPL
54 BOOST_HANA_NAMESPACE_END
56 #endif // !BOOST_HANA_DETAIL_DISPATCH_IF_HPP