1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright Matt Borland 2021.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// https://en.cppreference.com/w/cpp/experimental/is_detected
#ifndef BOOST_MATH_TOOLS_IS_DETECTED_HPP
#define BOOST_MATH_TOOLS_IS_DETECTED_HPP
#include <boost/math/tools/type_traits.hpp>
namespace boost { namespace math { namespace tools {
template <typename...>
using void_t = void;
namespace detail {
template <typename Default, typename AlwaysVoid, template<typename...> class Op, typename... Args>
struct detector
{
using value_t = boost::math::false_type;
using type = Default;
};
template <typename Default, template<typename...> class Op, typename... Args>
struct detector<Default, void_t<Op<Args...>>, Op, Args...>
{
using value_t = boost::math::true_type;
using type = Op<Args...>;
};
} // Namespace detail
// Special type to indicate detection failure
struct nonesuch
{
nonesuch() = delete;
~nonesuch() = delete;
nonesuch(const nonesuch&) = delete;
void operator=(const nonesuch&) = delete;
};
template <template<typename...> class Op, typename... Args>
using is_detected = typename detail::detector<nonesuch, void, Op, Args...>::value_t;
template <template<typename...> class Op, typename... Args>
using detected_t = typename detail::detector<nonesuch, void, Op, Args...>::type;
template <typename Default, template<typename...> class Op, typename... Args>
using detected_or = detail::detector<Default, void, Op, Args...>;
}}} // Namespaces boost math tools
#endif // BOOST_MATH_TOOLS_IS_DETECTED_HPP
|