Skip to content

Commit

Permalink
Mark constants as _INLINE_VAR constexpr. (microsoft#2792)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej authored and fsb4000 committed Aug 13, 2022
1 parent 24f5344 commit 6087c6c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion stl/inc/functional
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ private:
virtual const void* _Get() const noexcept = 0;
};

constexpr size_t _Space_size = (_Small_object_num_ptrs - 1) * sizeof(void*);
_INLINE_VAR constexpr size_t _Space_size = (_Small_object_num_ptrs - 1) * sizeof(void*);

template <class _Impl> // determine whether _Impl must be dynamically allocated
_INLINE_VAR constexpr bool _Is_large = sizeof(_Impl) > _Space_size || alignof(_Impl) > alignof(max_align_t)
Expand Down
16 changes: 8 additions & 8 deletions stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -1155,16 +1155,16 @@ _NODISCARD bool operator!=(const match_results<_BidIt, _Alloc>& _Left, const mat
}
#endif // !_HAS_CXX20

const unsigned int _BRE_MAX_GRP = 9U;
_INLINE_VAR constexpr unsigned int _BRE_MAX_GRP = 9U;

const unsigned int _Bmp_max = 256U; // must fit in an unsigned int
const unsigned int _Bmp_shift = 3U;
const unsigned int _Bmp_chrs = 1U << _Bmp_shift; // # of bits to be stored in each char
const unsigned int _Bmp_mask = _Bmp_chrs - 1U;
const unsigned int _Bmp_size = (_Bmp_max + _Bmp_chrs - 1U) / _Bmp_chrs;
_INLINE_VAR constexpr unsigned int _Bmp_max = 256U; // must fit in an unsigned int
_INLINE_VAR constexpr unsigned int _Bmp_shift = 3U;
_INLINE_VAR constexpr unsigned int _Bmp_chrs = 1U << _Bmp_shift; // # of bits to be stored in each char
_INLINE_VAR constexpr unsigned int _Bmp_mask = _Bmp_chrs - 1U;
_INLINE_VAR constexpr unsigned int _Bmp_size = (_Bmp_max + _Bmp_chrs - 1U) / _Bmp_chrs;

const unsigned int _Buf_incr = 16U;
const unsigned int _ARRAY_THRESHOLD = 4U;
_INLINE_VAR constexpr unsigned int _Buf_incr = 16U;
_INLINE_VAR constexpr unsigned int _ARRAY_THRESHOLD = 4U;

enum _Node_flags : int { // flags for nfa nodes with special properties
_Fl_none = 0x00,
Expand Down
5 changes: 3 additions & 2 deletions stl/inc/vector
Original file line number Diff line number Diff line change
Expand Up @@ -2108,8 +2108,9 @@ vector(_Iter, _Iter, _Alloc = _Alloc()) -> vector<_Iter_value_t<_Iter>, _Alloc>;
template <class _Alloc>
class vector<bool, _Alloc>;

using _Vbase = unsigned int; // word type for vector<bool> representation
constexpr int _VBITS = 8 * sizeof(_Vbase); // at least CHAR_BITS bits per word
using _Vbase = unsigned int; // word type for vector<bool> representation

_INLINE_VAR constexpr int _VBITS = 8 * sizeof(_Vbase); // at least CHAR_BITS bits per word

template <class _Ty, class _Alloc>
_NODISCARD _CONSTEXPR20 bool operator==(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) {
Expand Down
3 changes: 2 additions & 1 deletion stl/inc/xstring
Original file line number Diff line number Diff line change
Expand Up @@ -2324,8 +2324,9 @@ public:
size_type _Myres = 0; // current storage reserved for string
};

// get _Ty's size after being EBCO'd
template <class _Ty>
constexpr size_t _Size_after_ebco_v = is_empty_v<_Ty> ? 0 : sizeof(_Ty); // get _Ty's size after being EBCO'd
_INLINE_VAR constexpr size_t _Size_after_ebco_v = is_empty_v<_Ty> ? 0 : sizeof(_Ty);

struct _String_constructor_concat_tag {
// tag to select constructors used by basic_string's concatenation operators (operator+)
Expand Down

0 comments on commit 6087c6c

Please sign in to comment.