36 #ifndef YB_INC_ydef_h_
37 #define YB_INC_ydef_h_ 1
78 # define YB_IMPL_CPP __cplusplus
81 # define YB_IMPL_MSCPP _MSC_VER
82 # elif defined(__clang__)
83 # undef YB_IMPL_CLANGPP
84 # if defined(__apple_build_version__)
85 # define YB_IMPL_CLANGPP \
86 (40300 + __clang_patchlevel__)
88 # define YB_IMPL_CLANGPP \
89 (__clang__ * 10000 + __clang_minor__ * 100 \
90 + __clang_patchlevel__)
92 # elif defined(__GNUC__)
93 # undef YB_IMPL_GNUCPP
94 # define YB_IMPL_GNUCPP \
95 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
100 # error "This language implementation is not supported."
103 # error "This header is only for C++."
106 #if YB_IMPL_MSCPP >= 1400
107 # define _CRT_SECURE_NO_WARNINGS
117 #ifndef __has_feature
118 # define __has_feature(...) 0
121 #ifndef __has_extension
122 # define __has_extension(...) 0
132 #include <type_traits>
157 #define YPP_Join(x, y) YPP_Concat(x, y)
163 #define YPP_Concat(x, y) x ## y
177 #define yimpl(...) __VA_ARGS__
191 #undef YB_HAS_ALIGNAS
192 #define YB_HAS_ALIGNAS \
193 (__has_feature(cxx_alignas) || __has_extension(cxx_alignas) || \
194 YB_IMPL_GNUCPP >= 40800)
201 #undef YB_HAS_ALIGNOF
202 #define YB_HAS_ALIGNOF (YB_IMPL_CPP >= 201103L || YB_IMPL_GNUCPP >= 40500)
209 #undef YB_HAS_BUILTIN_NULLPTR
210 #define YB_HAS_BUILTIN_NULLPTR \
211 (__has_feature(cxx_nullptr) || __has_extension(cxx_nullptr) || \
212 YB_IMPL_CPP >= 201103L || YB_IMPL_GNUCPP >= 40600 || \
213 YB_IMPL_MSCPP >= 1600)
220 #undef YB_HAS_CONSTEXPR
221 #define YB_HAS_CONSTEXPR \
222 (__has_feature(cxx_constexpr) || YB_IMPL_CPP >= 201103L || \
223 YB_IMPL_GNUCPP >= 40600)
230 #undef YB_HAS_NOEXCEPT
231 #define YB_HAS_NOEXCEPT \
232 (__has_feature(cxx_noexcept) || __has_extension(cxx_noexcept) || \
233 YB_IMPL_CPP >= 201103L || YB_IMPL_GNUCPP >= 40600)
241 #undef YB_HAS_THREAD_LOCAL
242 #define YB_HAS_THREAD_LOCAL \
243 (__has_feature(cxx_thread_local) || (YB_IMPL_CPP >= 201103L \
244 && !YB_IMPL_GNUCPP) || YB_IMPL_GNUCPP >= 40800)
262 #if YB_IMPL_GNUCPP >= 20500
263 # define YB_ATTR(...) __attribute__((__VA_ARGS__))
265 # define YB_ATTR(...)
278 #if YB_IMPL_GNUCPP >= 20296
279 # define YB_ALLOCATOR YB_ATTR(__malloc__)
281 # define YB_ALLOCATOR
291 #if YB_IMPL_GNUCPP >= 29600
292 # define YB_EXPECT(expr, constant) (__builtin_expect(expr, constant))
293 # define YB_LIKELY(expr) (__builtin_expect(bool(expr), 1))
294 # define YB_UNLIKELY(expr) (__builtin_expect(bool(expr), 0))
296 # define YB_EXPECT(expr, constant) (expr)
297 # define YB_LIKELY(expr) (expr)
298 # define YB_UNLIKELY(expr) (expr)
308 #if YB_IMPL_GNUCPP >= 20296
309 # define YB_NORETURN YB_ATTR(__noreturn__)
328 #if YB_IMPL_GNUCPP >= 20296
329 # define YB_PURE YB_ATTR(__pure__)
351 #if YB_IMPL_GNUCPP >= 20500
352 # define YB_STATELESS YB_ATTR(__const__)
354 # define YB_STATELESS
382 #if defined(YB_DLL) && defined(YB_BUILD_DLL)
383 # error "DLL could not be built and used at the same time."
387 # define YB_API __declspec(dllimport)
388 #elif defined(YB_BUILD_DLL)
389 # define YB_API __declspec(dllexport)
406 # ifndef YB_Use_YAssert
407 # define YB_Use_YAssert 1
410 #define YB_Use_YTrace 1
418 #if 0 && !defined(NDEBUG)
419 # define YB_USE_EXCEPTION_SPECIFICATION 1
440 # define yalignof alignof
442 # define yalignof(_type) std::alignment_of<_type>::value
459 # define yconstexpr constexpr
460 # define yconstfn constexpr
462 # define yconstexpr const
463 # define yconstfn inline
473 #if YB_USE_EXCEPTION_SPECIFICATION
474 # define ythrow throw
491 #ifdef YB_USE_EXCEPTION_VALIDATION
492 # define ynothrowv ynothrow
510 # define ynothrow ynoexcept
511 #elif YB_IMPL_GNUCPP >= 30300
512 # define ynothrow __attribute__ ((nothrow))
514 # define ynothrow ythrow()
524 # define ynoexcept noexcept
526 # define ynoexcept(...)
536 #if YB_HAS_THREAD_LOCAL && defined(_MT)
537 # define ythread thread_local
539 # define ythread static
569 using std::ptrdiff_t;
573 #if YB_HAS_BUILTIN_NULLPTR
575 using std::nullptr_t;
589 template<
typename _type>
591 operator _type*()
const
599 template<
class _tClass,
typename _type>
601 operator _type _tClass::*()
const
608 template<
typename _type>
623 template<
typename _type>
629 template<
typename _type>
636 template<
typename _type>
642 template<
typename _type>
657 template<
typename...>
680 template<
bool _bMemObjPtr,
bool _bNoExcept,
class _type>
683 static_assert(std::is_class<_type>::value,
"Non class type found.");
684 static_assert(std::is_standard_layout<_type>::value,
685 "Non standard layout type found.");
686 static_assert(_bMemObjPtr,
"Non-static member object violation found.");
687 static_assert(_bNoExcept,
"Exception guarantee violation found.");
697 #define yunused(...) static_cast<void>(__VA_ARGS__)
707 #define yoffsetof(_type, _member) \
708 (decltype(sizeof(ystdex::offsetof_check<std::is_member_object_pointer< \
709 decltype(&_type::_member)>::value, ynoexcept(offsetof(_type, _member)), \
710 _type>))(offsetof(_type, _member)))
722 #define yforward(_expr) std::forward<decltype(_expr)>(_expr)
729 template<
typename _type,
typename... _tParams>
748 #define yunseq ystdex::unsequenced
bool operator!=(nullptr_t lhs, const _type &rhs)
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
bool equals(const _type &rhs) const
void operator&() const =delete
#define yconstfn
指定编译时常量函数。
auto unsequenced(_type &&arg, _tParams &&...) -> decltype(std::forward< decltype(arg)>(arg))
无序列依赖表达式组求值实现。
bool operator==(nullptr_t lhs, const _type &rhs)