1/*=============================================================================
2 Copyright (c) 2016 Paul Fultz II
3 intrinsics.hpp
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6==============================================================================*/
7
8#ifndef BOOST_HOF_GUARD_INTRINSICS_HPP
9#define BOOST_HOF_GUARD_INTRINSICS_HPP
10
11#include <type_traits>
12#include <boost/hof/detail/holder.hpp>
13#include <boost/hof/config.hpp>
14
15// *** clang ***
16#if defined(__clang__)
17// #define BOOST_HOF_IS_CONSTRUCTIBLE(...) std::is_constructible<__VA_ARGS__>::value
18// #define BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(...) std::is_nothrow_constructible<__VA_ARGS__>::value
19// #define BOOST_HOF_IS_CONVERTIBLE(...) std::is_convertible<__VA_ARGS__>::value
20#define BOOST_HOF_IS_CONSTRUCTIBLE(...) __is_constructible(__VA_ARGS__)
21#define BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(...) __is_nothrow_constructible(__VA_ARGS__)
22#define BOOST_HOF_IS_CONVERTIBLE(...) __is_convertible_to(__VA_ARGS__)
23#define BOOST_HOF_IS_BASE_OF(...) __is_base_of(__VA_ARGS__)
24#define BOOST_HOF_IS_CLASS(...) __is_class(__VA_ARGS__)
25#define BOOST_HOF_IS_EMPTY(...) __is_empty(__VA_ARGS__)
26#define BOOST_HOF_IS_LITERAL(...) __is_literal(__VA_ARGS__)
27#define BOOST_HOF_IS_POLYMORPHIC(...) __is_polymorphic(__VA_ARGS__)
28#define BOOST_HOF_IS_FINAL(...) __is_final(__VA_ARGS__)
29#define BOOST_HOF_IS_NOTHROW_COPY_CONSTRUCTIBLE(...) __has_nothrow_copy(__VA_ARGS__)
30// *** gcc ***
31#elif defined(__GNUC__)
32#define BOOST_HOF_IS_CONSTRUCTIBLE(...) std::is_constructible<__VA_ARGS__>::value
33#define BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(...) std::is_nothrow_constructible<__VA_ARGS__>::value
34#define BOOST_HOF_IS_CONVERTIBLE(...) std::is_convertible<__VA_ARGS__>::value
35#define BOOST_HOF_IS_BASE_OF(...) __is_base_of(__VA_ARGS__)
36#define BOOST_HOF_IS_CLASS(...) __is_class(__VA_ARGS__)
37#define BOOST_HOF_IS_EMPTY(...) __is_empty(__VA_ARGS__)
38#define BOOST_HOF_IS_LITERAL(...) __is_literal_type(__VA_ARGS__)
39#define BOOST_HOF_IS_POLYMORPHIC(...) __is_polymorphic(__VA_ARGS__)
40#define BOOST_HOF_IS_NOTHROW_COPY_CONSTRUCTIBLE(...) __has_nothrow_copy(__VA_ARGS__)
41#if __GNUC__ == 4 && __GNUC_MINOR__ < 7
42#define BOOST_HOF_IS_FINAL(...) (false)
43#else
44#define BOOST_HOF_IS_FINAL(...) __is_final(__VA_ARGS__)
45#endif
46#define BOOST_HOF_IS_NOTHROW_COPY_CONSTRUCTIBLE(...) __has_nothrow_copy(__VA_ARGS__)
47// *** other ***
48#else
49#define BOOST_HOF_IS_CONSTRUCTIBLE(...) std::is_constructible<__VA_ARGS__>::value
50#define BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(...) std::is_nothrow_constructible<__VA_ARGS__>::value
51#define BOOST_HOF_IS_CONVERTIBLE(...) std::is_convertible<__VA_ARGS__>::value
52#define BOOST_HOF_IS_BASE_OF(...) std::is_base_of<__VA_ARGS__>::value
53#define BOOST_HOF_IS_CLASS(...) std::is_class<__VA_ARGS__>::value
54#define BOOST_HOF_IS_EMPTY(...) std::is_empty<__VA_ARGS__>::value
55#ifdef _MSC_VER
56#define BOOST_HOF_IS_LITERAL(...) __is_literal_type(__VA_ARGS__)
57#else
58#define BOOST_HOF_IS_LITERAL(...) std::is_literal_type<__VA_ARGS__>::value
59#endif
60#define BOOST_HOF_IS_POLYMORPHIC(...) std::is_polymorphic<__VA_ARGS__>::value
61#if defined(_MSC_VER)
62#define BOOST_HOF_IS_NOTHROW_COPY_CONSTRUCTIBLE(...) (std::is_nothrow_copy_constructible<__VA_ARGS__>::value || std::is_reference<__VA_ARGS__>::value)
63#else
64#define BOOST_HOF_IS_NOTHROW_COPY_CONSTRUCTIBLE(...) std::is_nothrow_copy_constructible<__VA_ARGS__>::value
65#endif
66#if defined(_MSC_VER)
67#define BOOST_HOF_IS_FINAL(...) __is_final(__VA_ARGS__)
68#else
69#define BOOST_HOF_IS_FINAL(...) (false)
70#endif
71#endif
72
73#if BOOST_HOF_NO_STD_DEFAULT_CONSTRUCTIBLE
74#define BOOST_HOF_IS_DEFAULT_CONSTRUCTIBLE(...) boost::hof::detail::is_default_constructible_helper<__VA_ARGS__>::value
75#else
76#define BOOST_HOF_IS_DEFAULT_CONSTRUCTIBLE BOOST_HOF_IS_CONSTRUCTIBLE
77#endif
78
79#define BOOST_HOF_IS_NOTHROW_MOVE_CONSTRUCTIBLE(...) BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(__VA_ARGS__, __VA_ARGS__ &&)
80
81namespace boost { namespace hof { namespace detail {
82
83template<class T, class=void>
84struct is_default_constructible_check
85: std::false_type
86{};
87
88template<class T>
89struct is_default_constructible_check<T, typename holder<
90 decltype(T())
91>::type>
92: std::true_type
93{};
94
95template<class T>
96struct is_default_constructible_helper
97: std::conditional<(std::is_reference<T>::value),
98 std::false_type,
99 is_default_constructible_check<T>
100>::type
101{};
102
103template<class T, class... Xs>
104struct is_constructible
105: std::is_constructible<T, Xs...>
106{};
107
108template<class T>
109struct is_constructible<T>
110: is_default_constructible_helper<T>
111{};
112
113}
114
115}} // namespace boost::hof
116
117#endif
118

source code of boost/libs/hof/include/boost/hof/detail/intrinsics.hpp