1 #ifndef SILICIUM_SILICIUM_CONFIG_HPP
2 #define SILICIUM_SILICIUM_CONFIG_HPP
6 #include <boost/config.hpp>
7 #include <boost/cstdint.hpp>
8 #include <boost/version.hpp>
9 #include <boost/preprocessor/if.hpp>
12 # define SILICIUM_GCC ((__GNUC__ * 100) + __GNUC_MINOR__)
14 # define SILICIUM_GCC 0
18 # define SILICIUM_COMPILER_CXX11 1
19 # define SILICIUM_COMPILER_CXX14 1
20 #elif __cplusplus > 201103L
21 # define SILICIUM_COMPILER_CXX11 1
22 # define SILICIUM_COMPILER_CXX14 1
23 #elif __cplusplus >= 201103L
24 # define SILICIUM_COMPILER_CXX11 1
25 # define SILICIUM_COMPILER_CXX14 1
27 # define SILICIUM_COMPILER_CXX11 0
28 # define SILICIUM_COMPILER_CXX14 0
31 #ifdef BOOST_NO_EXCEPTIONS
32 # define SILICIUM_HAS_EXCEPTIONS 0
34 # define SILICIUM_HAS_EXCEPTIONS 1
37 #if defined(NDEBUG) || !SILICIUM_HAS_EXCEPTIONS
39 # define SILICIUM_UNREACHABLE() __assume(false)
41 # define SILICIUM_UNREACHABLE() __builtin_unreachable()
44 # define SILICIUM_UNREACHABLE() throw ::std::logic_error("unreachable " __FILE__ ":" BOOST_STRINGIZE(__LINE__))
47 #if (defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408)) || defined(__clang__) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
48 # define SILICIUM_COMPILER_GENERATES_MOVES 1
50 # define SILICIUM_COMPILER_GENERATES_MOVES 0
53 #if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408) || defined(__clang__) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
54 # define SILICIUM_COMPILER_HAS_WORKING_NOEXCEPT 1
56 # define SILICIUM_COMPILER_HAS_WORKING_NOEXCEPT 0
60 # define SILICIUM_NORETURN __declspec(noreturn)
63 # define SILICIUM_NORETURN __attribute__ ((__noreturn__))
66 #if (defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408)) || defined(__clang__) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
67 # define SILICIUM_COMPILER_HAS_RVALUE_THIS_QUALIFIER 1
69 # define SILICIUM_COMPILER_HAS_RVALUE_THIS_QUALIFIER 0
72 #if (defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408) && SILICIUM_COMPILER_CXX14) || defined(__clang__) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
73 # define SILICIUM_COMPILER_HAS_AUTO_RETURN_TYPE 1
75 # define SILICIUM_COMPILER_HAS_AUTO_RETURN_TYPE 0
78 #if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408) || defined(__clang__) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
79 # define SILICIUM_COMPILER_HAS_EXTENDED_CAPTURE 1
81 # define SILICIUM_COMPILER_HAS_EXTENDED_CAPTURE 0
84 #if SILICIUM_COMPILER_HAS_EXTENDED_CAPTURE
85 # define SILICIUM_CAPTURE_EXPRESSION(name, value) name = value
87 # define SILICIUM_CAPTURE_EXPRESSION(name, value) name
90 #if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 407) || defined(__clang__) || defined(_MSC_VER)
91 # define SILICIUM_COMPILER_HAS_VARIADIC_PACK_EXPANSION 1
93 # define SILICIUM_COMPILER_HAS_VARIADIC_PACK_EXPANSION 0
96 #if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 407) || defined(__clang__) || (defined(_MSC_VER) && (_MSC_VER != 1900)) //VS 2015 has a buggy variadic template using
97 # define SILICIUM_COMPILER_HAS_USING 1
99 # define SILICIUM_COMPILER_HAS_USING 0
102 #if defined(_MSC_VER) && (_MSC_VER < 1900)
103 # define SILICIUM_COMPILER_HAS_CXX11_UNION 0
105 # define SILICIUM_COMPILER_HAS_CXX11_UNION 1
108 #ifdef BOOST_DELETED_FUNCTION
109 # define SILICIUM_DELETED_FUNCTION BOOST_DELETED_FUNCTION
111 # define SILICIUM_DELETED_FUNCTION(f) private: f;
114 #define SILICIUM_DISABLE_COPY(struct_name) \
115 SILICIUM_DELETED_FUNCTION(struct_name(struct_name const &)) \
116 SILICIUM_DELETED_FUNCTION(struct_name &operator = (struct_name const &))
118 #define SILICIUM_DEFAULT_NOEXCEPT_MOVE(struct_name) \
119 struct_name(struct_name &&) BOOST_NOEXCEPT = default; \
120 struct_name &operator = (struct_name &&) BOOST_NOEXCEPT = default;
122 #define SILICIUM_DEFAULT_MOVE(struct_name) \
123 struct_name(struct_name &&) = default; \
124 struct_name &operator = (struct_name &&) = default;
126 #define SILICIUM_DEFAULT_COPY(struct_name) \
127 struct_name(struct_name const &) = default; \
128 struct_name &operator = (struct_name const &) = default;
131 # define SILICIUM_DEPRECATED __declspec(deprecated)
133 # define SILICIUM_DEPRECATED __attribute__((deprecated))
136 #if defined(__GNUC__) && (__GNUC__ <= 4) && (__GNUC__ < 4 || __GNUC_MINOR__ <= 6)
137 # define SILICIUM_OVERRIDE
138 # define SILICIUM_FINAL
140 # define SILICIUM_OVERRIDE override
141 # define SILICIUM_FINAL final
145 # define SILICIUM_USE_RESULT _Check_return_
147 # define SILICIUM_USE_RESULT __attribute__((warn_unused_result))
151 #define SILICIUM_CXX14_CONSTEXPR
153 #define SILICIUM_IF(condition, value) BOOST_PP_IF(condition, value, BOOST_PP_EMPTY())
154 #define SILICIUM_IF_NOT(condition, value) BOOST_PP_IF(condition, BOOST_PP_EMPTY(), value)
156 #define SILICIUM_MOVE_IF_COMPILER_LACKS_RVALUE_QUALIFIERS(should_be_rvalue) BOOST_PP_IF(SILICIUM_COMPILER_HAS_RVALUE_THIS_QUALIFIER, (should_be_rvalue), std::move((should_be_rvalue)))
172 template <
class T,
class ...Args>
175 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
178 template <
class To,
class From>
186 To result =
reinterpret_cast<To
>(from);
190 #if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 407) || defined(__clang__)
191 #define SILICIUM_HAS_PROPER_COPY_TRAITS 1
193 #include <type_traits>
196 using std::is_copy_constructible;
197 using std::is_copy_assignable;
198 #elif BOOST_VERSION >= 105500 //1.55
199 #define SILICIUM_HAS_PROPER_COPY_TRAITS 1
201 #include <boost/type_traits/is_copy_constructible.hpp>
202 #include <boost/type_traits/is_convertible.hpp>
204 #if SILICIUM_HAS_EXCEPTIONS
210 using boost::is_copy_constructible;
211 #if SILICIUM_HAS_EXCEPTIONS
213 struct is_copy_constructible<
std::future<T>> : std::false_type
218 struct is_copy_assignable : std::true_type
221 #if SILICIUM_HAS_EXCEPTIONS
223 struct is_copy_assignable<
std::future<T>> : std::false_type
227 template <
class T,
class D>
228 struct is_copy_assignable<
std::unique_ptr<T, D>> : std::false_type
232 #define SILICIUM_HAS_PROPER_COPY_TRAITS 0
243 #if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 407) || defined(__clang__) || defined(_MSC_VER)
245 #include <type_traits>
248 using std::is_default_constructible;
249 using std::is_move_assignable;
250 using std::is_move_constructible;
251 using std::is_nothrow_default_constructible;
252 using std::is_nothrow_move_constructible;
253 using std::is_nothrow_move_assignable;
254 using std::is_nothrow_destructible;
258 std::is_reference<T>::value,
260 std::is_constructible<T>
298 #if BOOST_VERSION <= 105400
299 # if defined(_MSC_VER) && (_MSC_VER < 1900)
Definition: config.hpp:160
Definition: config.hpp:265
Definition: config.hpp:277
Definition: absolute_path.hpp:352
Definition: absolute_path.hpp:19
auto make_unique(Args &&...args) -> std::unique_ptr< T >
Definition: config.hpp:173
Definition: config.hpp:257
Definition: config.hpp:238
SILICIUM_USE_RESULT bool operator==(absolute_path const &left, ComparableToPath const &right)
Definition: absolute_path.hpp:169
std::uintptr_t uintptr_t
Definition: config.hpp:302
Definition: config.hpp:269
Definition: config.hpp:289
To function_ptr_cast(From from)
Definition: config.hpp:179
Definition: config.hpp:281
BOOST_CONSTEXPR nothing() BOOST_NOEXCEPT
Definition: config.hpp:162
Definition: config.hpp:234
Definition: config.hpp:273