36 #ifndef YB_INC_ydef_h_
37 #define YB_INC_ydef_h_ 1
70 # define YB_IMPL_CPP __cplusplus
73 # define YB_IMPL_MSCPP _MSC_VER
74 # elif defined(__GNUC__)
75 # undef YB_IMPL_GNUCPP
76 # define YB_IMPL_GNUCPP (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 \
77 + __GNUC_PATCHLEVEL__)
82 # error This language implementation is not supported!
85 # error This header is only for C++!
96 #include <type_traits>
110 #undef YB_HAS_ALIGNAS
111 #define YB_HAS_ALIGNAS (YB_IMPL_GNUCPP >= 40800)
118 #undef YB_HAS_ALIGNOF
119 #define YB_HAS_ALIGNOF (YB_IMPL_CPP >= 201103L || YB_IMPL_GNUCPP >= 40500)
126 #undef YB_HAS_BUILTIN_NULLPTR
127 #define YB_HAS_BUILTIN_NULLPTR (YB_IMPL_CPP >= 201103L \
128 || YB_IMPL_GNUCPP >= 40600 || YB_IMPL_MSCPP >= 1600)
135 #undef YB_HAS_CONSTEXPR
136 #define YB_HAS_CONSTEXPR (YB_IMPL_CPP >= 201103L || YB_IMPL_GNUCPP >= 40600)
143 #undef YB_HAS_NOEXCEPT
144 #define YB_HAS_NOEXCEPT (YB_IMPL_CPP >= 201103L || YB_IMPL_GNUCPP >= 40600)
163 #if YB_IMPL_GNUCPP >= 20500
164 # define YB_ATTR(...) __attribute__((__VA_ARGS__))
166 # define YB_ATTR(...)
179 #if YB_IMPL_GNUCPP >= 20296
180 # define YB_ALLOCATOR YB_ATTR(__malloc__)
182 # define YB_ALLOCATOR
192 #if YB_IMPL_GNUCPP >= 29600
193 # define YB_EXPECT(expr, constant) (__builtin_expect(expr, constant))
194 # define YB_LIKELY(expr) (__builtin_expect(bool(expr), 1))
195 # define YB_UNLIKELY(expr) (__builtin_expect(bool(expr), 0))
197 # define YB_EXPECT(expr, constant) (expr)
198 # define YB_LIKELY (expr) (expr)
199 # define YB_UNLIKELY (expr) (expr)
209 #if YB_IMPL_GNUCPP >= 20296
210 # define YB_NORETURN YB_ATTR(__noreturn__)
229 #if YB_IMPL_GNUCPP >= 20296
230 # define YB_PURE YB_ATTR(__pure__)
252 #if YB_IMPL_GNUCPP >= 20500
253 # define YB_STATELESS YB_ATTR(__const__)
255 # define YB_STATELESS
283 #if defined(YB_DLL) && defined(YB_BUILD_DLL)
284 # error DLL could not be built and used at the same time!
288 # define YB_API __declspec(dllimport)
289 #elif defined(YB_BUILD_DLL)
290 # define YB_API __declspec(dllexport)
302 # define YB_USE_YASSERT
312 # define YB_USE_EXCEPTION_SPECIFICATION 1
334 # define yalignof alignof
336 # define yalignof(_type) std::alignment_of<_type>::value
353 # define yconstexpr constexpr
354 # define yconstfn constexpr
356 # define yconstexpr const
357 # define yconstfn inline
367 #if YB_USE_EXCEPTION_SPECIFICATION
368 # define ythrow throw
378 #ifdef YB_HAS_NOEXCEPT
379 # define ynothrow ynoexcept
381 # define ynothrow ythrow()
391 # define ynoexcept noexcept
393 # define ynoexcept(...)
406 #define yconstraint assert
417 #define yassume assert
432 using std::ptrdiff_t;
436 #if YB_HAS_BUILTIN_NULLPTR
438 using std::nullptr_t;
452 template<
typename _type>
453 inline operator _type*()
const
461 template<
class _tClass,
typename _type>
462 inline operator _type _tClass::*()
const
469 template<
typename _type>
bool
483 template<
typename _type>
489 template<
typename _type>
496 template<
typename _type>
502 template<
typename _type>
517 template<
typename...>
534 template<
bool _bMemObjPtr,
bool _bNoExcept,
class _type>
537 static_assert(std::is_class<_type>::value,
"Non class type found.");
538 static_assert(std::is_standard_layout<_type>::value,
539 "Non standard layout type found.");
540 static_assert(_bMemObjPtr,
"Non-static member object violation found.");
541 static_assert(_bNoExcept,
"Exception guarantee violation found.");
553 #define yoffsetof(_type, _member) \
554 (decltype(sizeof(ystdex::offsetof_check<std::is_member_object_pointer< \
555 decltype(&_type::_member)>::value, ynoexcept(offsetof(_type, _member)), \
556 _type>))(offsetof(_type, _member)))
569 #define yforward(_expr) std::forward<decltype(_expr)>(_expr)
576 template<
typename _type,
typename... _tParams>
595 #define yunseq ystdex::unsequenced