-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathcstddef
103 lines (81 loc) · 3.39 KB
/
cstddef
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
// cstddef standard header (core)
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#pragma once
#ifndef _CSTDDEF_
#define _CSTDDEF_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <stddef.h>
#include <xtr1common>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
using _CSTD ptrdiff_t;
using _CSTD size_t;
using max_align_t = double; // most aligned type
#ifdef __cpp_lib_byte
enum class byte : unsigned char {};
template <class _IntType, enable_if_t<is_integral_v<_IntType>, int> = 0>
_NODISCARD constexpr byte operator<<(const byte _Arg, const _IntType _Shift) noexcept {
// every static_cast is intentional
return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(_Arg) << _Shift));
}
template <class _IntType, enable_if_t<is_integral_v<_IntType>, int> = 0>
_NODISCARD constexpr byte operator>>(const byte _Arg, const _IntType _Shift) noexcept {
// every static_cast is intentional
return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(_Arg) >> _Shift));
}
_NODISCARD constexpr byte operator|(const byte _Left, const byte _Right) noexcept {
// every static_cast is intentional
return static_cast<byte>(
static_cast<unsigned char>(static_cast<unsigned int>(_Left) | static_cast<unsigned int>(_Right)));
}
_NODISCARD constexpr byte operator&(const byte _Left, const byte _Right) noexcept {
// every static_cast is intentional
return static_cast<byte>(
static_cast<unsigned char>(static_cast<unsigned int>(_Left) & static_cast<unsigned int>(_Right)));
}
_NODISCARD constexpr byte operator^(const byte _Left, const byte _Right) noexcept {
// every static_cast is intentional
return static_cast<byte>(
static_cast<unsigned char>(static_cast<unsigned int>(_Left) ^ static_cast<unsigned int>(_Right)));
}
_NODISCARD constexpr byte operator~(const byte _Arg) noexcept {
// every static_cast is intentional
return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(_Arg)));
}
template <class _IntType, enable_if_t<is_integral_v<_IntType>, int> = 0>
constexpr byte& operator<<=(byte& _Arg, const _IntType _Shift) noexcept {
return _Arg = _Arg << _Shift;
}
template <class _IntType, enable_if_t<is_integral_v<_IntType>, int> = 0>
constexpr byte& operator>>=(byte& _Arg, const _IntType _Shift) noexcept {
return _Arg = _Arg >> _Shift;
}
constexpr byte& operator|=(byte& _Left, const byte _Right) noexcept {
return _Left = _Left | _Right;
}
constexpr byte& operator&=(byte& _Left, const byte _Right) noexcept {
return _Left = _Left & _Right;
}
constexpr byte& operator^=(byte& _Left, const byte _Right) noexcept {
return _Left = _Left ^ _Right;
}
template <class _IntType, enable_if_t<is_integral_v<_IntType>, int> = 0>
_NODISCARD constexpr _IntType to_integer(const byte _Arg) noexcept {
return static_cast<_IntType>(_Arg);
}
#endif // __cpp_lib_byte
_STD_END
using _STD max_align_t; // intentional, for historical reasons
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _CSTDDEF_