金牌会员
- 积分
- 1765
- 金钱
- 1765
- 注册时间
- 2015-9-21
- 在线时间
- 544 小时
|
- // new standard header
- // Copyright (c) Microsoft Corporation.
- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- #pragma once//为了避免同一个头文件被包含多次
- #ifndef _NEW_
- #define _NEW_
- #include <yvals_core.h>
- #if _STL_COMPILER_PREPROCESSOR
- #include <exception>
- #include <vcruntime_new.h>
- #pragma pack(push, _CRT_PACKING)//#pragma pack指定结构、联合和类的包对齐方式
- #pragma warning(push, _STL_WARNING_LEVEL)//#pragma warning该指令允许有选择的修改编译器的警告消息的行为
- #pragma warning(disable : _STL_DISABLED_WARNINGS)
- _STL_DISABLE_CLANG_WARNINGS
- #pragma push_macro("new")
- /*
- *#pragma push_macro把括号中的内容(宏)的值压入堆栈
- * #pragma pop_macro把括号中的内容(宏)的值弹出堆栈
- */
- #undef new
- _STD_BEGIN
- #ifdef __cpp_lib_destroying_delete
- // STRUCT destroying_delete_t
- struct destroying_delete_t {
- explicit destroying_delete_t() = default;
- };
- inline constexpr destroying_delete_t destroying_delete{};
- #endif // __cpp_lib_destroying_delete
- #if _HAS_CXX17
- // FUNCTION TEMPLATE launder
- template <class _Ty>
- _NODISCARD constexpr _Ty* launder(_Ty* _Ptr) noexcept {
- static_assert(!is_function_v<_Ty> && !is_void_v<_Ty>,
- "N4727 21.6.4 [ptr.launder]/3: The program is ill-formed if T is a function type or cv void.");
- return __builtin_launder(_Ptr);
- }
- #if defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64)
- inline constexpr size_t hardware_constructive_interference_size = 64;
- inline constexpr size_t hardware_destructive_interference_size = 64;
- #else // ^^^ supported hardware ^^^ // vvv unsupported hardware vvv
- #error Unsupported architecture
- //#error命令时C/C++语言的预处理命令之一,当预处理器预处理到#error命令时将停止编译并输出用户自定义的错误消息TOU
- #endif // hardware
- #endif // _HAS_CXX17
- // SUPPORT TYPES
- #if !defined(_INC_NEW) || !defined(_MSC_EXTENSIONS)
- // handler for operator new failures
- using new_handler = void(__CLRCALL_PURE_OR_CDECL*)();
- #endif // !defined(_INC_NEW) || !defined(_MSC_EXTENSIONS)
- // FUNCTION AND OBJECT DECLARATIONS
- _CRTIMP2 new_handler __cdecl set_new_handler(_In_opt_ new_handler) noexcept;
- _NODISCARD _CRTIMP2 new_handler __cdecl get_new_handler() noexcept;
- _STD_END
- #pragma pop_macro("new")
- _STL_RESTORE_CLANG_WARNINGS
- #pragma warning(pop)
- #pragma pack(pop)
- #endif // _STL_COMPILER_PREPROCESSOR
- #endif // _NEW_
复制代码
|
|