Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
433 changes: 2 additions & 431 deletions stl/inc/algorithm

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions stl/inc/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,11 @@ template <class _Integral, class _Ty>
_NODISCARD _Integral _Atomic_reinterpret_as(const _Ty& _Source) noexcept {
// interprets _Source as the supplied integral type
static_assert(is_integral_v<_Integral>, "Tried to reinterpret memory as non-integral");
#if _HAS_IF_CONSTEXPR
if constexpr (is_integral_v<_Ty> && sizeof(_Integral) == sizeof(_Ty)) {
return static_cast<_Integral>(_Source);
} else if constexpr (is_pointer_v<_Ty> && sizeof(_Integral) == sizeof(_Ty)) {
return reinterpret_cast<_Integral>(_Source);
} else
#endif // _HAS_IF_CONSTEXPR
{
} else {
_Integral _Result{}; // zero padding bits
_CSTD memcpy(&_Result, _STD addressof(_Source), sizeof(_Source));
return _Result;
Expand Down
16 changes: 8 additions & 8 deletions stl/inc/bitset
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,12 @@ public:
constexpr bool _Bits_zero = _Bits == 0;
constexpr bool _Bits_small = _Bits <= 32;
constexpr bool _Bits_large = _Bits > 64;
if _CONSTEXPR_IF (_Bits_zero) {
if constexpr (_Bits_zero) {
return 0;
} else if _CONSTEXPR_IF (_Bits_small) {
} else if constexpr (_Bits_small) {
return static_cast<unsigned long>(_Array[0]);
} else {
if _CONSTEXPR_IF (_Bits_large) {
if constexpr (_Bits_large) {
for (size_t _Idx = 1; _Idx <= _Words; ++_Idx) {
if (_Array[_Idx] != 0) {
_Xoflo(); // fail if any high-order words are nonzero
Expand All @@ -306,10 +306,10 @@ public:
_NODISCARD unsigned long long to_ullong() const {
constexpr bool _Bits_zero = _Bits == 0;
constexpr bool _Bits_large = _Bits > 64;
if _CONSTEXPR_IF (_Bits_zero) {
if constexpr (_Bits_zero) {
return 0;
} else {
if _CONSTEXPR_IF (_Bits_large) {
if constexpr (_Bits_large) {
for (size_t _Idx = 1; _Idx <= _Words; ++_Idx) {
if (_Array[_Idx] != 0) {
_Xoflo(); // fail if any high-order words are nonzero
Expand Down Expand Up @@ -398,7 +398,7 @@ public:

_NODISCARD bool all() const noexcept {
constexpr bool _Zero_length = _Bits == 0;
if _CONSTEXPR_IF (_Zero_length) { // must test for this, otherwise would count one full word
if constexpr (_Zero_length) { // must test for this, otherwise would count one full word
return true;
}

Expand Down Expand Up @@ -432,7 +432,7 @@ private:

void _Trim() noexcept { // clear any trailing bits in last word
constexpr bool _Work_to_do = _Bits == 0 || _Bits % _Bitsperword != 0;
if _CONSTEXPR_IF (_Work_to_do) {
if constexpr (_Work_to_do) {
_Array[_Words] &= (_Ty{1} << _Bits % _Bitsperword) - 1;
}
}
Expand Down Expand Up @@ -534,7 +534,7 @@ basic_istream<_Elem, _Tr>& operator>>(basic_istream<_Elem, _Tr>& _Istr, bitset<_

constexpr bool _Has_bits = _Bits > 0;

if _CONSTEXPR_IF (_Has_bits) {
if constexpr (_Has_bits) {
if (!_Changed) {
_State |= _Istr_t::failbit;
}
Expand Down
36 changes: 0 additions & 36 deletions stl/inc/cmath
Original file line number Diff line number Diff line change
Expand Up @@ -562,67 +562,31 @@ double frexp(_Ty _Value, _Out_ int* const _Exp) noexcept /* strengthened */ {
}

// FUNCTION TEMPLATE fma
#if !_HAS_IF_CONSTEXPR
inline float _Fma(float _Left, float _Middle, float _Right) noexcept {
return _CSTD fmaf(_Left, _Middle, _Right);
}

inline double _Fma(double _Left, double _Middle, double _Right) noexcept {
return _CSTD fma(_Left, _Middle, _Right);
}

inline long double _Fma(long double _Left, long double _Middle, long double _Right) noexcept {
return _CSTD fmal(_Left, _Middle, _Right);
}
#endif // !_HAS_IF_CONSTEXPR

template <class _Ty1, class _Ty2, class _Ty3,
_STD enable_if_t<_STD is_arithmetic_v<_Ty1> && _STD is_arithmetic_v<_Ty2> && _STD is_arithmetic_v<_Ty3>, int> = 0>
_NODISCARD _STD _Common_float_type_t<_Ty1, _STD _Common_float_type_t<_Ty2, _Ty3>> fma(
_Ty1 _Left, _Ty2 _Middle, _Ty3 _Right) noexcept /* strengthened */ {
using _Common = _STD _Common_float_type_t<_Ty1, _STD _Common_float_type_t<_Ty2, _Ty3>>;
#if _HAS_IF_CONSTEXPR
if constexpr (_STD is_same_v<_Common, float>) {
return _CSTD fmaf(static_cast<_Common>(_Left), static_cast<_Common>(_Middle), static_cast<_Common>(_Right));
} else if constexpr (_STD is_same_v<_Common, double>) {
return _CSTD fma(static_cast<_Common>(_Left), static_cast<_Common>(_Middle), static_cast<_Common>(_Right));
} else {
return _CSTD fmal(static_cast<_Common>(_Left), static_cast<_Common>(_Middle), static_cast<_Common>(_Right));
}
#else // ^^^ use "if constexpr" dispatch / use overload resolution vvv
return _Fma(static_cast<_Common>(_Left), static_cast<_Common>(_Middle), static_cast<_Common>(_Right));
#endif // _HAS_IF_CONSTEXPR
}

// FUNCTION TEMPLATE remquo
#if !_HAS_IF_CONSTEXPR
inline float _Remquo(float _Left, float _Right, int* _Pquo) noexcept {
return _CSTD remquof(_Left, _Right, _Pquo);
}

inline double _Remquo(double _Left, double _Right, int* _Pquo) noexcept {
return _CSTD remquo(_Left, _Right, _Pquo);
}

inline long double _Remquo(long double _Left, long double _Right, int* _Pquo) noexcept {
return _CSTD remquol(_Left, _Right, _Pquo);
}
#endif // !_HAS_IF_CONSTEXPR

template <class _Ty1, class _Ty2, _STD enable_if_t<_STD is_arithmetic_v<_Ty1> && _STD is_arithmetic_v<_Ty2>, int> = 0>
_STD _Common_float_type_t<_Ty1, _Ty2> remquo(_Ty1 _Left, _Ty2 _Right, int* _Pquo) noexcept /* strengthened */ {
using _Common = _STD _Common_float_type_t<_Ty1, _Ty2>;
#if _HAS_IF_CONSTEXPR
if constexpr (_STD is_same_v<_Common, float>) {
return _CSTD remquof(static_cast<_Common>(_Left), static_cast<_Common>(_Right), _Pquo);
} else if constexpr (_STD is_same_v<_Common, double>) {
return _CSTD remquo(static_cast<_Common>(_Left), static_cast<_Common>(_Right), _Pquo);
} else {
return _CSTD remquol(static_cast<_Common>(_Left), static_cast<_Common>(_Right), _Pquo);
}
#else // ^^^ use "if constexpr" dispatch / use overload resolution vvv
return _Remquo(static_cast<_Common>(_Left), static_cast<_Common>(_Right), _Pquo);
#endif // _HAS_IF_CONSTEXPR
}

#define _GENERIC_MATH1_BASE(NAME, RET, FUN) \
Expand Down
12 changes: 6 additions & 6 deletions stl/inc/codecvt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected:
*_Pstate = 1;

constexpr bool _Consuming = (_Mymode & consume_header) != 0;
if _CONSTEXPR_IF (_Consuming) {
if constexpr (_Consuming) {
if (_Ch == 0xfeff) { // drop header and retry
const result _Ans = do_in(_State, _Mid1, _Last1, _Mid1, _First2, _Last2, _Mid2);

Expand Down Expand Up @@ -159,7 +159,7 @@ protected:
if (*_Pstate == 0) { // first time, maybe generate header
*_Pstate = 1;
constexpr bool _Generating = (_Mymode & generate_header) != 0;
if _CONSTEXPR_IF (_Generating) {
if constexpr (_Generating) {
if (_Last2 - _Mid2 < 3 + 1 + _Nextra) {
return _Mybase::partial; // not enough room for both
}
Expand Down Expand Up @@ -254,15 +254,15 @@ protected:
constexpr bool _Prefer_LE = (_Mymode & little_endian) != 0;
constexpr char _Default_endian = _Prefer_LE ? _Little_first : _Big_first;

if _CONSTEXPR_IF (_Prefer_LE) {
if constexpr (_Prefer_LE) {
_Ch0 = static_cast<unsigned short>(_Ptr[1] << 8 | _Ptr[0]);
} else {
_Ch0 = static_cast<unsigned short>(_Ptr[0] << 8 | _Ptr[1]);
}

*_Pstate = _Default_endian;
constexpr bool _Consuming = (_Mymode & consume_header) != 0;
if _CONSTEXPR_IF (_Consuming) {
if constexpr (_Consuming) {
if (_Ch0 == 0xfffeu) {
*_Pstate = 3 - _Default_endian;
}
Expand Down Expand Up @@ -321,7 +321,7 @@ protected:
if (*_Pstate == 0) { // determine endianness once, maybe generate header
*_Pstate = (_Mymode & little_endian) != 0 ? _Little_first : _Big_first;
constexpr bool _Generating = (_Mymode & generate_header) != 0;
if _CONSTEXPR_IF (_Generating) {
if constexpr (_Generating) {
if (_Last2 - _Mid2 < 3 * _Bytes_per_word) {
return _Mybase::partial; // not enough room for all
}
Expand Down Expand Up @@ -536,7 +536,7 @@ protected:
*_Pstate = 1;

constexpr bool _Consuming = (_Mymode & consume_header) != 0;
if _CONSTEXPR_IF (_Consuming) {
if constexpr (_Consuming) {
if (_Ch == 0xfeffu) { // drop header and retry
result _Ans = do_in(_State, _Mid1, _Last1, _Mid1, _First2, _Last2, _Mid2);

Expand Down
16 changes: 6 additions & 10 deletions stl/inc/cvt/one_one
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new

#if !_HAS_IF_CONSTEXPR
#pragma warning(disable : 4127) // conditional expression is constant
#endif // !_HAS_IF_CONSTEXPR

namespace stdext {
namespace cvt {

Expand Down Expand Up @@ -75,7 +71,7 @@ namespace stdext {
constexpr unsigned char _Default_endian = static_cast<unsigned char>(
(_Mode & _STD little_endian) != 0 ? _STD _Little_first : _STD _Big_first);

if _CONSTEXPR_IF ((_Mode & _STD little_endian) != 0) {
if constexpr ((_Mode & _STD little_endian) != 0) {
for (_Count = _Bytes_per_word; 0 < _Count;) {
_Ch = _Ch << 8 | _Ptr[--_Count];
}
Expand All @@ -85,7 +81,7 @@ namespace stdext {
}
}

if _CONSTEXPR_IF ((_Mode & _STD consume_header) == 0) {
if constexpr ((_Mode & _STD consume_header) == 0) {
*_Pstate = _Default_endian;
} else if (_Ch != 0xfeff && _Ch != (0xfffe0000 >> 8 * (4 - _Bytes_per_word))) {
*_Pstate = _Default_endian;
Expand Down Expand Up @@ -124,13 +120,13 @@ namespace stdext {
if (*_Pstate == 0) { // determine endianness once, maybe generate header
unsigned long _Header = 0xfeff;

if _CONSTEXPR_IF ((_Mode & _STD little_endian) != 0) {
if constexpr ((_Mode & _STD little_endian) != 0) {
*_Pstate = _STD _Little_first;
} else {
*_Pstate = _STD _Big_first;
}

if _CONSTEXPR_IF ((_Mode & _STD generate_header) == 0) {
if constexpr ((_Mode & _STD generate_header) == 0) {
(void) _Header; // unused
} else if (_Last2 - _Mid2 < 2 * _Bytes_per_word) {
return _Mybase::partial; // not enough room for both
Expand Down Expand Up @@ -216,15 +212,15 @@ namespace stdext {
}

virtual int do_max_length() const noexcept override { // return maximum length required for a conversion
if _CONSTEXPR_IF ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
if constexpr ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
return 2 * _Bytes_per_word;
} else {
return _Bytes_per_word;
}
}

virtual int do_encoding() const noexcept override { // return length of code sequence (from codecvt)
if _CONSTEXPR_IF ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
if constexpr ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
return -1; // -1 => state dependent
} else {
return static_cast<int>(_Bytes_per_word);
Expand Down
16 changes: 6 additions & 10 deletions stl/inc/cvt/utf16
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new

#if !_HAS_IF_CONSTEXPR
#pragma warning(disable : 4127) // conditional expression is constant
#endif // !_HAS_IF_CONSTEXPR

namespace stdext {
namespace cvt {
using _Statype = _CSTD mbstate_t;
Expand Down Expand Up @@ -69,13 +65,13 @@ namespace stdext {
constexpr unsigned char _Default_endian = static_cast<unsigned char>(
(_Mode & _STD little_endian) != 0 ? _STD _Little_first : _STD _Big_first);

if _CONSTEXPR_IF ((_Mode & _STD little_endian) != 0) {
if constexpr ((_Mode & _STD little_endian) != 0) {
_Ch0 = static_cast<unsigned short>(_Ptr[1] << 8 | _Ptr[0]);
} else {
_Ch0 = static_cast<unsigned short>(_Ptr[0] << 8 | _Ptr[1]);
}

if _CONSTEXPR_IF ((_Mode & _STD consume_header) == 0) {
if constexpr ((_Mode & _STD consume_header) == 0) {
*_Pstate = _Default_endian;
} else if (_Ch0 != 0xfeff && _Ch0 != 0xfffe) {
*_Pstate = _Default_endian;
Expand Down Expand Up @@ -130,13 +126,13 @@ namespace stdext {
_Mid2 = _First2;

if (*_Pstate == 0) { // determine endianness once, maybe generate header
if _CONSTEXPR_IF ((_Mode & _STD little_endian) != 0) {
if constexpr ((_Mode & _STD little_endian) != 0) {
*_Pstate = _STD _Little_first;
} else {
*_Pstate = _STD _Big_first;
}

if _CONSTEXPR_IF ((_Mode & _STD generate_header) != 0) {
if constexpr ((_Mode & _STD generate_header) != 0) {
if (_Last2 - _Mid2 < 3 * _Bytes_per_word) {
return _Mybase::partial; // not enough room for both
}
Expand Down Expand Up @@ -245,15 +241,15 @@ namespace stdext {
}

virtual int do_max_length() const noexcept override { // return maximum length required for a conversion
if _CONSTEXPR_IF ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
if constexpr ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
return 3 * _Bytes_per_word;
} else {
return 6 * _Bytes_per_word;
}
}

virtual int do_encoding() const noexcept override { // return length of code sequence (from codecvt)
if _CONSTEXPR_IF ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
if constexpr ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
return -1; // -1 => state dependent
} else {
return 0; // 0 => varying length
Expand Down
12 changes: 4 additions & 8 deletions stl/inc/cvt/utf8
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new

#if !_HAS_IF_CONSTEXPR
#pragma warning(disable : 4127) // conditional expression is constant
#endif // !_HAS_IF_CONSTEXPR

namespace stdext {
namespace cvt {

Expand Down Expand Up @@ -96,7 +92,7 @@ namespace stdext {
if (*_Pstate == 0) { // first time, maybe look for and consume header
*_Pstate = 1;

if _CONSTEXPR_IF ((_Mode & _STD consume_header) != 0) {
if constexpr ((_Mode & _STD consume_header) != 0) {
if (_Ch == 0xfeff) { // drop header and retry
result _Ans = do_in(_State, _Mid1, _Last1, _Mid1, _First2, _Last2, _Mid2);

Expand Down Expand Up @@ -157,7 +153,7 @@ namespace stdext {
if (*_Pstate == 0) { // first time, maybe generate header
*_Pstate = 1;

if _CONSTEXPR_IF ((_Mode & _STD generate_header) != 0) {
if constexpr ((_Mode & _STD generate_header) != 0) {
if (_Last2 - _Mid2 < 3 + 1 + _Nextra) {
return _Mybase::partial; // not enough room for both
}
Expand Down Expand Up @@ -224,15 +220,15 @@ namespace stdext {
}

virtual int do_max_length() const noexcept override { // return maximum length required for a conversion
if _CONSTEXPR_IF ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
if constexpr ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
return 9;
} else {
return 6;
}
}

virtual int do_encoding() const noexcept override { // return length of code sequence (from codecvt)
if _CONSTEXPR_IF ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
if constexpr ((_Mode & (_STD consume_header | _STD generate_header)) != 0) {
return -1; // -1 => state dependent
} else {
return 0; // 0 => varying length
Expand Down
Loading