Blame view

3rdparty/boost_1_81_0/boost/hof/detail/intrinsics.hpp 4.54 KB
63e88f80   Hu Chunming   提交三方库
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
  /*=============================================================================
      Copyright (c) 2016 Paul Fultz II
      intrinsics.hpp
      Distributed under 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)
  ==============================================================================*/
  
  #ifndef BOOST_HOF_GUARD_INTRINSICS_HPP
  #define BOOST_HOF_GUARD_INTRINSICS_HPP
  
  #include <type_traits>
  #include <boost/hof/detail/holder.hpp>
  #include <boost/hof/config.hpp>
  
  // *** clang ***
  #if defined(__clang__)
  // #define BOOST_HOF_IS_CONSTRUCTIBLE(...) std::is_constructible<__VA_ARGS__>::value
  // #define BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(...) std::is_nothrow_constructible<__VA_ARGS__>::value
  // #define BOOST_HOF_IS_CONVERTIBLE(...) std::is_convertible<__VA_ARGS__>::value
  #define BOOST_HOF_IS_CONSTRUCTIBLE(...) __is_constructible(__VA_ARGS__)
  #define BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(...) __is_nothrow_constructible(__VA_ARGS__)
  #define BOOST_HOF_IS_CONVERTIBLE(...) __is_convertible_to(__VA_ARGS__)
  #define BOOST_HOF_IS_BASE_OF(...) __is_base_of(__VA_ARGS__)
  #define BOOST_HOF_IS_CLASS(...) __is_class(__VA_ARGS__)
  #define BOOST_HOF_IS_EMPTY(...) __is_empty(__VA_ARGS__)
  #define BOOST_HOF_IS_LITERAL(...) __is_literal(__VA_ARGS__)
  #define BOOST_HOF_IS_POLYMORPHIC(...) __is_polymorphic(__VA_ARGS__)
  #define BOOST_HOF_IS_FINAL(...) __is_final(__VA_ARGS__)
  #define BOOST_HOF_IS_NOTHROW_COPY_CONSTRUCTIBLE(...) __has_nothrow_copy(__VA_ARGS__)
  // *** gcc ***
  #elif defined(__GNUC__)
  #define BOOST_HOF_IS_CONSTRUCTIBLE(...) std::is_constructible<__VA_ARGS__>::value
  #define BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(...) std::is_nothrow_constructible<__VA_ARGS__>::value
  #define BOOST_HOF_IS_CONVERTIBLE(...) std::is_convertible<__VA_ARGS__>::value
  #define BOOST_HOF_IS_BASE_OF(...) __is_base_of(__VA_ARGS__)
  #define BOOST_HOF_IS_CLASS(...) __is_class(__VA_ARGS__)
  #define BOOST_HOF_IS_EMPTY(...) __is_empty(__VA_ARGS__)
  #define BOOST_HOF_IS_LITERAL(...) __is_literal_type(__VA_ARGS__)
  #define BOOST_HOF_IS_POLYMORPHIC(...) __is_polymorphic(__VA_ARGS__)
  #define BOOST_HOF_IS_NOTHROW_COPY_CONSTRUCTIBLE(...) __has_nothrow_copy(__VA_ARGS__)
  #if __GNUC__ == 4 && __GNUC_MINOR__ < 7
  #define BOOST_HOF_IS_FINAL(...) (false)
  #else
  #define BOOST_HOF_IS_FINAL(...) __is_final(__VA_ARGS__)
  #endif
  #define BOOST_HOF_IS_NOTHROW_COPY_CONSTRUCTIBLE(...) __has_nothrow_copy(__VA_ARGS__)
  // *** other ***
  #else
  #define BOOST_HOF_IS_CONSTRUCTIBLE(...) std::is_constructible<__VA_ARGS__>::value
  #define BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(...) std::is_nothrow_constructible<__VA_ARGS__>::value
  #define BOOST_HOF_IS_CONVERTIBLE(...) std::is_convertible<__VA_ARGS__>::value
  #define BOOST_HOF_IS_BASE_OF(...) std::is_base_of<__VA_ARGS__>::value
  #define BOOST_HOF_IS_CLASS(...) std::is_class<__VA_ARGS__>::value
  #define BOOST_HOF_IS_EMPTY(...) std::is_empty<__VA_ARGS__>::value
  #ifdef _MSC_VER
  #define BOOST_HOF_IS_LITERAL(...) __is_literal_type(__VA_ARGS__)
  #else
  #define BOOST_HOF_IS_LITERAL(...) std::is_literal_type<__VA_ARGS__>::value
  #endif
  #define BOOST_HOF_IS_POLYMORPHIC(...) std::is_polymorphic<__VA_ARGS__>::value
  #if defined(_MSC_VER)
  #define BOOST_HOF_IS_NOTHROW_COPY_CONSTRUCTIBLE(...) (std::is_nothrow_copy_constructible<__VA_ARGS__>::value || std::is_reference<__VA_ARGS__>::value)
  #else
  #define BOOST_HOF_IS_NOTHROW_COPY_CONSTRUCTIBLE(...) std::is_nothrow_copy_constructible<__VA_ARGS__>::value
  #endif
  #if defined(_MSC_VER)
  #define BOOST_HOF_IS_FINAL(...) __is_final(__VA_ARGS__)
  #else
  #define BOOST_HOF_IS_FINAL(...) (false)
  #endif
  #endif
  
  #if BOOST_HOF_NO_STD_DEFAULT_CONSTRUCTIBLE
  #define BOOST_HOF_IS_DEFAULT_CONSTRUCTIBLE(...) boost::hof::detail::is_default_constructible_helper<__VA_ARGS__>::value
  #else
  #define BOOST_HOF_IS_DEFAULT_CONSTRUCTIBLE BOOST_HOF_IS_CONSTRUCTIBLE
  #endif
  
  #define BOOST_HOF_IS_NOTHROW_MOVE_CONSTRUCTIBLE(...) BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(__VA_ARGS__, __VA_ARGS__ &&)
  
  namespace boost { namespace hof { namespace detail {
  
  template<class T, class=void>
  struct is_default_constructible_check
  : std::false_type
  {};
  
  template<class T>
  struct is_default_constructible_check<T, typename holder<
      decltype(T())
  >::type>
  : std::true_type
  {};
  
  template<class T>
  struct is_default_constructible_helper
  : std::conditional<(std::is_reference<T>::value), 
      std::false_type,
      is_default_constructible_check<T>
  >::type
  {};
  
  template<class T, class... Xs>
  struct is_constructible
  : std::is_constructible<T, Xs...>
  {};
  
  template<class T>
  struct is_constructible<T>
  : is_default_constructible_helper<T>
  {};
  
  }
  
  }} // namespace boost::hof
  
  #endif