Skip to content

Commit 18d8f37

Browse files
Various cleanups (#2140)
1 parent 7565738 commit 18d8f37

File tree

28 files changed

+69
-87
lines changed

28 files changed

+69
-87
lines changed

stl/inc/algorithm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ _STD_BEGIN
4141
_INLINE_VAR constexpr int _ISORT_MAX = 32; // maximum size for insertion sort
4242

4343
template <class _It>
44-
_INLINE_VAR constexpr auto _Isort_max = _Iter_diff_t<_It>{_ISORT_MAX};
44+
_INLINE_VAR constexpr _Iter_diff_t<_It> _Isort_max{_ISORT_MAX};
4545

4646
template <class _Diff>
4747
constexpr ptrdiff_t _Temporary_buffer_size(const _Diff _Value) noexcept {

stl/inc/cvt/wbuffer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ namespace stdext {
254254
if (_Mystrbuf && _Status != _Wrote) {
255255
// got buffer, haven't written, try to compose an element
256256
if (_Status != _Eof) {
257-
if (_Str.size() == 0) {
257+
if (_Str.empty()) {
258258
_Status = _Need;
259259
} else {
260260
_Status = _Got;

stl/inc/exception

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,25 +264,27 @@ public:
264264
return __ExceptionPtrCompare(&_Lhs, &_Rhs);
265265
}
266266

267-
_NODISCARD friend bool operator==(nullptr_t, const exception_ptr& _Rhs) noexcept {
268-
return !_Rhs;
269-
}
270-
271267
_NODISCARD friend bool operator==(const exception_ptr& _Lhs, nullptr_t) noexcept {
272268
return !_Lhs;
273269
}
274270

271+
#if !_HAS_CXX20
272+
_NODISCARD friend bool operator==(nullptr_t, const exception_ptr& _Rhs) noexcept {
273+
return !_Rhs;
274+
}
275+
275276
_NODISCARD friend bool operator!=(const exception_ptr& _Lhs, const exception_ptr& _Rhs) noexcept {
276277
return !(_Lhs == _Rhs);
277278
}
278279

279-
_NODISCARD friend bool operator!=(nullptr_t _Lhs, const exception_ptr& _Rhs) noexcept {
280+
_NODISCARD friend bool operator!=(const exception_ptr& _Lhs, nullptr_t _Rhs) noexcept {
280281
return !(_Lhs == _Rhs);
281282
}
282283

283-
_NODISCARD friend bool operator!=(const exception_ptr& _Lhs, nullptr_t _Rhs) noexcept {
284+
_NODISCARD friend bool operator!=(nullptr_t _Lhs, const exception_ptr& _Rhs) noexcept {
284285
return !(_Lhs == _Rhs);
285286
}
287+
#endif // !_HAS_CXX20
286288

287289
private:
288290
#ifdef __clang__

stl/inc/experimental/coroutine

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ namespace experimental {
8888
return _Ptr;
8989
}
9090

91-
__declspec(
92-
deprecated("is deprecated. Use coroutine_handle::address() instead")) void* to_address() const noexcept {
91+
[[deprecated("coroutine_handle::to_address() is deprecated. "
92+
"Use coroutine_handle::address() instead.")]] void*
93+
to_address() const noexcept {
9394
return _Ptr;
9495
}
9596

@@ -131,8 +132,9 @@ namespace experimental {
131132
struct coroutine_handle : coroutine_handle<> { // general form
132133
using coroutine_handle<>::coroutine_handle;
133134

134-
__declspec(deprecated("with pointer parameter is deprecated. Use coroutine_handle::from_promise(T&) "
135-
"instead")) static coroutine_handle from_promise(_PromiseT* _Prom) noexcept {
135+
[[deprecated("coroutine_handle::from_promise(T*) with pointer parameter is deprecated. "
136+
"Use coroutine_handle::from_promise(T&) instead.")]] static coroutine_handle
137+
from_promise(_PromiseT* _Prom) noexcept {
136138
return from_promise(*_Prom);
137139
}
138140

stl/inc/future

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ public:
11571157
}
11581158

11591159
_NODISCARD future<_Ty> get_future() {
1160-
return future<_Ty>(_MyPromise._Get_state_for_future(), _Nil());
1160+
return future<_Ty>(_MyPromise._Get_state_for_future(), _Nil{});
11611161
}
11621162

11631163
void set_value(const _Ty& _Val) {
@@ -1219,7 +1219,7 @@ public:
12191219
}
12201220

12211221
_NODISCARD future<_Ty&> get_future() {
1222-
return future<_Ty&>(_MyPromise._Get_state_for_future(), _Nil());
1222+
return future<_Ty&>(_MyPromise._Get_state_for_future(), _Nil{});
12231223
}
12241224

12251225
void set_value(_Ty& _Val) {
@@ -1273,7 +1273,7 @@ public:
12731273
}
12741274

12751275
_NODISCARD future<void> get_future() {
1276-
return future<void>(_MyPromise._Get_state_for_future(), _Nil());
1276+
return future<void>(_MyPromise._Get_state_for_future(), _Nil{});
12771277
}
12781278

12791279
void set_value() {
@@ -1365,7 +1365,7 @@ public:
13651365
}
13661366

13671367
_NODISCARD future<_Ret> get_future() {
1368-
return future<_Ret>(_MyPromise._Get_state_for_future(), _Nil());
1368+
return future<_Ret>(_MyPromise._Get_state_for_future(), _Nil{});
13691369
}
13701370

13711371
void operator()(_ArgTypes... _Args) {
@@ -1494,7 +1494,7 @@ _NODISCARD future<_Invoke_result_t<decay_t<_Fty>, decay_t<_ArgTypes>...>> async(
14941494
_Get_associated_state<_Ret>(_Policy, _Fake_no_copy_callable_adapter<_Fty, _ArgTypes...>(
14951495
_STD forward<_Fty>(_Fnarg), _STD forward<_ArgTypes>(_Args)...)));
14961496

1497-
return future<_Ret>(_Pr._Get_state_for_future(), _Nil());
1497+
return future<_Ret>(_Pr._Get_state_for_future(), _Nil{});
14981498
}
14991499

15001500
template <class _Fty, class... _ArgTypes>

stl/inc/random

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3011,7 +3011,7 @@ private:
30113011
_LogSx = _STD log(_Sx) + static_cast<_Ty>(_ExpMax) * (_Ln2 * 2);
30123012
}
30133013

3014-
const auto _Fx = _Ty{_STD sqrt(_Ty{-2} * _LogSx / _Sx)};
3014+
const _Ty _Fx{_STD sqrt(_Ty{-2} * _LogSx / _Sx)};
30153015
if (_Keep) { // save second value for next call
30163016
_Xx2 = _Fx * _Vx2;
30173017
_Valid = true;

stl/inc/stdatomic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include <yvals.h>
1010
#if _STL_COMPILER_PREPROCESSOR
1111

12+
#ifndef __cplusplus
13+
#error <stdatomic.h> is not yet supported when compiling as C, but this is planned for a future release.
14+
#endif // __cplusplus
15+
1216
#ifdef _M_CEE_PURE
1317
#error <stdatomic.h> is not supported when compiling with /clr:pure.
1418
#endif // _M_CEE_PURE

stl/inc/string

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ _NODISCARD inline int stoi(const string& _Str, size_t* _Idx = nullptr, int _Base
9595
_Xinvalid_argument("invalid stoi argument");
9696
}
9797

98-
if (_Errno_ref == ERANGE || _Ans < INT_MIN || INT_MAX < _Ans) {
98+
if (_Errno_ref == ERANGE) {
9999
_Xout_of_range("stoi argument out of range");
100100
}
101101

@@ -276,7 +276,7 @@ _NODISCARD inline int stoi(const wstring& _Str, size_t* _Idx = nullptr, int _Bas
276276
_Xinvalid_argument("invalid stoi argument");
277277
}
278278

279-
if (_Errno_ref == ERANGE || _Ans < INT_MIN || INT_MAX < _Ans) {
279+
if (_Errno_ref == ERANGE) {
280280
_Xout_of_range("stoi argument out of range");
281281
}
282282

stl/inc/tuple

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ constexpr _Ret _Tuple_cat(index_sequence<_Kx...>, index_sequence<_Ix...>, _Ty&&
963963
template <class... _Tuples>
964964
_NODISCARD constexpr typename _Tuple_cat1<_Tuples...>::type tuple_cat(_Tuples&&... _Tpls) { // concatenate tuples
965965
using _Cat1 = _Tuple_cat1<_Tuples...>;
966-
return _Tuple_cat<typename _Cat1::type>(typename _Cat1::_Kx_arg_seq(), typename _Cat1::_Ix_arg_seq(),
966+
return _Tuple_cat<typename _Cat1::type>(typename _Cat1::_Kx_arg_seq{}, typename _Cat1::_Ix_arg_seq{},
967967
_STD forward_as_tuple(_STD forward<_Tuples>(_Tpls)...));
968968
}
969969

stl/inc/xcharconv_ryu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ _NODISCARD inline uint64_t __double_to_bits(const double __d) {
134134
// vvvvvvvvvv DERIVED FROM d2s.h vvvvvvvvvv
135135

136136
inline constexpr int __DOUBLE_MANTISSA_BITS = 52;
137-
inline constexpr int __DOUBLE_EXPONENT_BITS = 11;
138137
inline constexpr int __DOUBLE_BIAS = 1023;
139138

140139
inline constexpr int __DOUBLE_POW5_INV_BITCOUNT = 122;
@@ -950,7 +949,6 @@ _NODISCARD inline to_chars_result __d2exp_buffered_n(char* _First, char* const _
950949
// vvvvvvvvvv DERIVED FROM f2s.c vvvvvvvvvv
951950

952951
inline constexpr int __FLOAT_MANTISSA_BITS = 23;
953-
inline constexpr int __FLOAT_EXPONENT_BITS = 8;
954952
inline constexpr int __FLOAT_BIAS = 127;
955953

956954
// This table is generated by PrintFloatLookupTable.

0 commit comments

Comments
 (0)