Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various cleanups #2140

Merged
Merged
Show file tree
Hide file tree
Changes from 11 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
2 changes: 1 addition & 1 deletion stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ _STD_BEGIN
_INLINE_VAR constexpr int _ISORT_MAX = 32; // maximum size for insertion sort

template <class _It>
_INLINE_VAR constexpr auto _Isort_max = _Iter_diff_t<_It>{_ISORT_MAX};
_INLINE_VAR constexpr _Iter_diff_t<_It> _Isort_max{_ISORT_MAX};

template <class _Diff>
constexpr ptrdiff_t _Temporary_buffer_size(const _Diff _Value) noexcept {
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/cvt/wbuffer
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ namespace stdext {
if (_Mystrbuf && _Status != _Wrote) {
// got buffer, haven't written, try to compose an element
if (_Status != _Eof) {
if (_Str.size() == 0) {
if (_Str.empty()) {
_Status = _Need;
} else {
_Status = _Got;
Expand Down
14 changes: 8 additions & 6 deletions stl/inc/exception
Original file line number Diff line number Diff line change
Expand Up @@ -264,25 +264,27 @@ public:
return __ExceptionPtrCompare(&_Lhs, &_Rhs);
}

_NODISCARD friend bool operator==(nullptr_t, const exception_ptr& _Rhs) noexcept {
return !_Rhs;
}

_NODISCARD friend bool operator==(const exception_ptr& _Lhs, nullptr_t) noexcept {
return !_Lhs;
}

#if !_HAS_CXX20
_NODISCARD friend bool operator==(nullptr_t, const exception_ptr& _Rhs) noexcept {
return !_Rhs;
}

_NODISCARD friend bool operator!=(const exception_ptr& _Lhs, const exception_ptr& _Rhs) noexcept {
return !(_Lhs == _Rhs);
}

_NODISCARD friend bool operator!=(nullptr_t _Lhs, const exception_ptr& _Rhs) noexcept {
_NODISCARD friend bool operator!=(const exception_ptr& _Lhs, nullptr_t _Rhs) noexcept {
return !(_Lhs == _Rhs);
}

_NODISCARD friend bool operator!=(const exception_ptr& _Lhs, nullptr_t _Rhs) noexcept {
_NODISCARD friend bool operator!=(nullptr_t _Lhs, const exception_ptr& _Rhs) noexcept {
return !(_Lhs == _Rhs);
}
#endif // !_HAS_CXX20

private:
#ifdef __clang__
Expand Down
10 changes: 5 additions & 5 deletions stl/inc/future
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ public:
}

_NODISCARD future<_Ty> get_future() {
return future<_Ty>(_MyPromise._Get_state_for_future(), _Nil());
return future<_Ty>(_MyPromise._Get_state_for_future(), _Nil{});
}

void set_value(const _Ty& _Val) {
Expand Down Expand Up @@ -1219,7 +1219,7 @@ public:
}

_NODISCARD future<_Ty&> get_future() {
return future<_Ty&>(_MyPromise._Get_state_for_future(), _Nil());
return future<_Ty&>(_MyPromise._Get_state_for_future(), _Nil{});
}

void set_value(_Ty& _Val) {
Expand Down Expand Up @@ -1273,7 +1273,7 @@ public:
}

_NODISCARD future<void> get_future() {
return future<void>(_MyPromise._Get_state_for_future(), _Nil());
return future<void>(_MyPromise._Get_state_for_future(), _Nil{});
}

void set_value() {
Expand Down Expand Up @@ -1365,7 +1365,7 @@ public:
}

_NODISCARD future<_Ret> get_future() {
return future<_Ret>(_MyPromise._Get_state_for_future(), _Nil());
return future<_Ret>(_MyPromise._Get_state_for_future(), _Nil{});
}

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

return future<_Ret>(_Pr._Get_state_for_future(), _Nil());
return future<_Ret>(_Pr._Get_state_for_future(), _Nil{});
}

template <class _Fty, class... _ArgTypes>
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/random
Original file line number Diff line number Diff line change
Expand Up @@ -3011,7 +3011,7 @@ private:
_LogSx = _STD log(_Sx) + static_cast<_Ty>(_ExpMax) * (_Ln2 * 2);
}

const auto _Fx = _Ty{_STD sqrt(_Ty{-2} * _LogSx / _Sx)};
const _Ty _Fx{_STD sqrt(_Ty{-2} * _LogSx / _Sx)};
if (_Keep) { // save second value for next call
_Xx2 = _Fx * _Vx2;
_Valid = true;
Expand Down
4 changes: 4 additions & 0 deletions stl/inc/stdatomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include <yvals.h>
#if _STL_COMPILER_PREPROCESSOR

#ifndef __cplusplus
#error <stdatomic.h> is not yet supported when compiling as C, but this is planned for a future release.
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved
#endif // __cplusplus

#ifdef _M_CEE_PURE
#error <stdatomic.h> is not supported when compiling with /clr:pure.
#endif // _M_CEE_PURE
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ constexpr _Ret _Tuple_cat(index_sequence<_Kx...>, index_sequence<_Ix...>, _Ty&&
template <class... _Tuples>
_NODISCARD constexpr typename _Tuple_cat1<_Tuples...>::type tuple_cat(_Tuples&&... _Tpls) { // concatenate tuples
using _Cat1 = _Tuple_cat1<_Tuples...>;
return _Tuple_cat<typename _Cat1::type>(typename _Cat1::_Kx_arg_seq(), typename _Cat1::_Ix_arg_seq(),
return _Tuple_cat<typename _Cat1::type>(typename _Cat1::_Kx_arg_seq{}, typename _Cat1::_Ix_arg_seq{},
_STD forward_as_tuple(_STD forward<_Tuples>(_Tpls)...));
}

Expand Down
2 changes: 0 additions & 2 deletions stl/inc/xcharconv_ryu.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ _NODISCARD inline uint64_t __double_to_bits(const double __d) {
// vvvvvvvvvv DERIVED FROM d2s.h vvvvvvvvvv

inline constexpr int __DOUBLE_MANTISSA_BITS = 52;
inline constexpr int __DOUBLE_EXPONENT_BITS = 11;
inline constexpr int __DOUBLE_BIAS = 1023;

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

inline constexpr int __FLOAT_MANTISSA_BITS = 23;
inline constexpr int __FLOAT_EXPONENT_BITS = 8;
inline constexpr int __FLOAT_BIAS = 127;

// This table is generated by PrintFloatLookupTable.
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/xlocmon
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ protected:
_State |= ios_base::eofbit;
}

if (_Str.size() == 0) {
if (_Str.empty()) {
_State |= ios_base::failbit; // _Getmfld failed
} else { // convert to long double
const char* _Eb = _Str.c_str();
Expand Down Expand Up @@ -476,7 +476,7 @@ private:
int _Fracdigseen = 0;
int _Fracdigits = _Ppunct_fac->frac_digits();
const string _Grouping = _Ppunct_fac->grouping();
const _Elem _Kseparator = _Grouping.size() == 0 ? _Elem{} : _Ppunct_fac->thousands_sep();
const _Elem _Kseparator = _Grouping.empty() ? _Elem{} : _Ppunct_fac->thousands_sep();

if (_Kseparator == _Elem{} || CHAR_MAX <= static_cast<unsigned char>(*_Grouping.c_str())) {
for (; _First != _Last && (_Idx = _Find_elem(_Atoms, *_First)) < 10; ++_First) {
Expand Down Expand Up @@ -540,7 +540,7 @@ private:
}
}

if (_Val.size() == 0) {
if (_Val.empty()) {
_Bad = true; // fail if no elements parsed
} else {
for (; _Fracdigseen < _Fracdigits; ++_Fracdigseen) {
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/xlocnum
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ private:
const locale& _Loc) const { // get integer field from [_First, _Last) into _Ac
const auto& _Punct_fac = _STD use_facet<numpunct<_Elem>>(_Loc);
const string _Grouping = _Punct_fac.grouping();
const _Elem _Kseparator = _Grouping.size() == 0 ? _Elem{} : _Punct_fac.thousands_sep();
const _Elem _Kseparator = _Grouping.empty() ? _Elem{} : _Punct_fac.thousands_sep();

constexpr int _Numget_signoff = 22;
constexpr int _Numget_xoff = 24;
Expand Down Expand Up @@ -812,7 +812,7 @@ private:
}
}
} else { // grouping specified, gather digits and group sizes
const _Elem _Kseparator = _Grouping.size() == 0 ? _Elem{} : _Punct_fac.thousands_sep();
const _Elem _Kseparator = _Grouping.empty() ? _Elem{} : _Punct_fac.thousands_sep();
string _Groups(1, '\0');
size_t _Group = 0;

Expand Down Expand Up @@ -1003,7 +1003,7 @@ private:
}
}
} else { // grouping specified, gather digits and group sizes
const _Elem _Kseparator = _Grouping.size() == 0 ? _Elem{} : _Punct_fac.thousands_sep();
const _Elem _Kseparator = _Grouping.empty() ? _Elem{} : _Punct_fac.thousands_sep();
string _Groups(1, '\0');
size_t _Group = 0;

Expand Down
4 changes: 2 additions & 2 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -1280,10 +1280,10 @@ struct _Distance_unknown {
};

template <class _Diff>
_INLINE_VAR constexpr auto _Max_possible_v = _Diff{static_cast<make_unsigned_t<_Diff>>(-1) >> 1};
_INLINE_VAR constexpr _Diff _Max_possible_v{static_cast<make_unsigned_t<_Diff>>(-1) >> 1};

template <class _Diff>
_INLINE_VAR constexpr auto _Min_possible_v = _Diff{-_Max_possible_v<_Diff> - 1};
_INLINE_VAR constexpr _Diff _Min_possible_v{-_Max_possible_v<_Diff> - 1};

template <class _Iter, class = void>
_INLINE_VAR constexpr bool _Offset_verifiable_v = false;
Expand Down
2 changes: 1 addition & 1 deletion stl/src/cthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace {
*b.started = 1;
_Cnd_signal(*b.cond);
_Mtx_unlock(*b.mtx);
const unsigned int res = (b.func) (b.data);
const unsigned int res = b.func(b.data);
_Cnd_do_broadcast_at_thread_exit();
return res;
}
Expand Down
2 changes: 1 addition & 1 deletion stl/src/fiopen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FILE* _Xfsopen(_In_z_ const wchar_t* filename, _In_ int mode, _In_ int prot) {
return _wfsopen(filename, mods[mode], prot);
}

template <typename CharT>
template <class CharT>
FILE* _Xfiopen(const CharT* filename, ios_base::openmode mode, int prot) {
static const int valid[] = {
// valid combinations of open flags
Expand Down
11 changes: 1 addition & 10 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,7 @@ std/utilities/memory/default.allocator/allocator.members/allocate.verify.cpp SKI


# *** MISSING STL FEATURES ***
# C++23 P1048R1 "is_scoped_enum"
std/utilities/meta/meta.unary/meta.unary.prop/is_scoped_enum.pass.cpp FAIL

# C++23 P1679R3 "contains() For basic_string/basic_string_view"
std/strings/basic.string/string.contains/contains.char.pass.cpp FAIL
std/strings/basic.string/string.contains/contains.ptr.pass.cpp FAIL
std/strings/basic.string/string.contains/contains.string_view.pass.cpp FAIL
std/strings/string.view/string.view.template/contains.char.pass.cpp FAIL
std/strings/string.view/string.view.template/contains.ptr.pass.cpp FAIL
std/strings/string.view/string.view.template/contains.string_view.pass.cpp FAIL
# Nothing here! :-)


# *** MISSING COMPILER FEATURES ***
Expand Down
11 changes: 1 addition & 10 deletions tests/libcxx/skipped_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,7 @@ utilities\memory\default.allocator\allocator.members\allocate.verify.cpp


# *** MISSING STL FEATURES ***
# C++23 P1048R1 "is_scoped_enum"
utilities\meta\meta.unary\meta.unary.prop\is_scoped_enum.pass.cpp

# C++23 P1679R3 "contains() For basic_string/basic_string_view"
strings\basic.string\string.contains\contains.char.pass.cpp
strings\basic.string\string.contains\contains.ptr.pass.cpp
strings\basic.string\string.contains\contains.string_view.pass.cpp
strings\string.view\string.view.template\contains.char.pass.cpp
strings\string.view\string.view.template\contains.ptr.pass.cpp
strings\string.view\string.view.template\contains.string_view.pass.cpp
# Nothing here! :-)


# *** MISSING COMPILER FEATURES ***
Expand Down
2 changes: 1 addition & 1 deletion tests/std/include/test_death.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <string>
#include <vector>

#include <test_windows.hpp>
#include <Windows.h>

namespace std_testing {
constexpr int internal_failure = 103;
Expand Down
2 changes: 1 addition & 1 deletion tests/std/include/test_thread_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <stdlib.h>
#include <thread>
#ifdef _MSC_EXTENSIONS
#include <test_windows.hpp>
#include <Windows.h>
#endif // _MSC_EXTENSIONS

class one_shot {
Expand Down
6 changes: 0 additions & 6 deletions tests/std/include/test_windows.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion tests/std/tests/Dev08_563686_ostream/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <sstream>
#include <stdlib.h>

#include <test_windows.hpp>
#include <Windows.h>

int main() {
// Track CRT blocks
Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/Dev09_056375_locale_cleanup/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <locale>
#include <stdio.h>

#include <test_windows.hpp>
#include <Windows.h>

using namespace std;

Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/Dev09_056375_locale_cleanup/testdll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>
#include <locale>

#include <test_windows.hpp>
#include <Windows.h>

using namespace std;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <future>
#endif // _M_CEE

#include <test_windows.hpp>
#include <Windows.h>

using namespace std;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <system_error>
#include <wctype.h>

#include <test_windows.hpp>
#include <Windows.h>

using namespace std;
namespace fs = std::experimental::filesystem;
Expand Down
8 changes: 4 additions & 4 deletions tests/std/tests/VSO_0226079_mutex/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <thread>
#include <utility>

#include <test_windows.hpp>
#include <Windows.h>

using namespace std;
using namespace std::chrono;
Expand Down Expand Up @@ -339,10 +339,10 @@ struct mutex_test_fixture {
}

// nonstandard xtime type
template <class rep, class period>
xtime to_xtime(const chrono::duration<rep, period>& rel_time) { // convert duration to xtime
template <class Rep, class Period>
xtime to_xtime(const chrono::duration<Rep, Period>& rel_time) { // convert duration to xtime
xtime xt;
if (rel_time <= chrono::duration<rep, period>::zero()) { // negative or zero relative time, return zero
if (rel_time <= chrono::duration<Rep, Period>::zero()) { // negative or zero relative time, return zero
xt.sec = 0;
xt.nsec = 0;
} else { // positive relative time, convert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <atomic>
#include <stdio.h>

#include <test_windows.hpp>
#include <Windows.h>

int main() {
// A customer wanted to read a std::atomic from a read-only memory-mapped file.
Expand Down