Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
10f26f0
`mutex.cpp`, `cond.cpp`: Use static dispatch (#3770)
cpplearner Jun 22, 2023
518f449
Fix `fstream.seekp(0, ios::cur)` (#3773)
achabense Jun 22, 2023
51fd0c0
Avoid evil macros (#3776)
StephanTLavavej Jun 22, 2023
ac138a5
Don't include `<limits>` in `<xutility>` (#3777)
frederick-vs-ja Jun 22, 2023
1b532be
Implement LWG-3904 lazy_split_view::outer-iterator's const-converting…
frederick-vs-ja Jun 22, 2023
9a85476
Implement LWG-3893 LWG-3661 broke `atomic<shared_ptr<T>> a; a = nullp…
frederick-vs-ja Jun 22, 2023
9e07371
Documentation Fix for #3780 (#3784)
JacobOgle Jun 22, 2023
f6d61a8
Documentation fix for #3779 (#3785)
Ashad001 Jun 22, 2023
4768199
`<format>`: Move the major part of `visit_format_arg` into a member f…
frederick-vs-ja Jun 22, 2023
057adf2
`<format>`: fix `std::format("{:#.precision}", floating)` (#3815)
achabense Jun 22, 2023
c5f1960
Standard Library Modules: Add workaround for `<format>` `/utf-8` (#3816)
StephanTLavavej Jun 22, 2023
40640c6
Deallocate at least (#3819)
CaseyCarter Jun 23, 2023
2261f7e
Revert `fstream.seekp(0, ios::cur)` change (#3841)
StephanTLavavej Jun 30, 2023
23a5a53
Toolset update: VS 2022 17.7 Preview 3, Clang 16.0.5 (#3866)
StephanTLavavej Jul 14, 2023
90dcf26
`<iterator>`: Modernize and deprecate `(un)checked_array_iterator` (#…
frederick-vs-ja Jul 14, 2023
cc6533a
Implement P2538R1 ADL-Proof `projected` (#3822)
frederick-vs-ja Jul 14, 2023
f155b41
Test coverage for LWG-2682 `filesystem::copy()` won't create a symlin…
frederick-vs-ja Jul 14, 2023
7c7cc0c
Add `[[msvc::lifetimebound]]` to `minmax` (#3831)
statementreply Jul 14, 2023
ab57910
add specialization for 24MHz QueryPerformanceFrequency (#3832)
fsb4000 Jul 14, 2023
068ce67
C++26 freestanding feature-test macros (#3837)
frederick-vs-ja Jul 14, 2023
b32f3b4
`<ranges>`: Improve implementation of recommended practices in `views…
JMazurkiewicz Jul 14, 2023
85eb9b6
`<functional>`: Make `function::target` return null function pointers…
frederick-vs-ja Jul 14, 2023
f6401b1
enhancements for `<filesystem>` (#3850)
achabense Jul 14, 2023
06d607c
Update _MSVC_STL_UPDATE (#3851)
duanqn Jul 14, 2023
a916571
Initialize array<T, 0>'s single element (#3863)
CaseyCarter Jul 14, 2023
171066e
Reallocate at least (#3864)
CaseyCarter Jul 14, 2023
df4dc31
`<functional>`: Deleted `operator()` overloads for return types of `b…
frederick-vs-ja Jul 14, 2023
2b8a19b
Test coverage and precondition checking for LWG-2295 Locale name when…
frederick-vs-ja Jul 14, 2023
5c91cbb
Optimizations for `<format>` (#3826)
achabense Jul 14, 2023
750ec42
Enhancements for `<bitset>` (#3838)
achabense Jul 14, 2023
828fa10
Strengthen exception specification for some facet base types (#3855)
frederick-vs-ja Jul 14, 2023
0574f20
Add `[[noreturn]]` for some functions (#3865)
achabense Jul 14, 2023
28ea30a
fix writing NaN to the output stream with a set locale (#3868)
fsb4000 Jul 14, 2023
f51733c
`<filesystem>`: fix dangerous `noexcept` specification of `_Current_p…
achabense Jul 14, 2023
f754151
Merge branch 'main' into flat_set-merge
StephanTLavavej Jul 14, 2023
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 .github/workflows/update-status-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ">=17.8.0"
node-version: ">=20.4.0"
- name: Install Packages
run: |
npm ci
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem

# How To Build With The Visual Studio IDE

1. Install Visual Studio 2022 17.7 Preview 2 or later.
1. Install Visual Studio 2022 17.7 Preview 3 or later.
* Select "Windows 11 SDK (10.0.22000.0)" in the VS Installer.
* We recommend selecting "C++ CMake tools for Windows" in the VS Installer.
This will ensure that you're using supported versions of CMake and Ninja.
Expand All @@ -157,7 +157,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem

# How To Build With A Native Tools Command Prompt

1. Install Visual Studio 2022 17.7 Preview 2 or later.
1. Install Visual Studio 2022 17.7 Preview 3 or later.
* Select "Windows 11 SDK (10.0.22000.0)" in the VS Installer.
* We recommend selecting "C++ CMake tools for Windows" in the VS Installer.
This will ensure that you're using supported versions of CMake and Ninja.
Expand Down
2 changes: 1 addition & 1 deletion azure-devops/create-1es-hosted-pool.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $ErrorActionPreference = 'Stop'
$CurrentDate = Get-Date

$Location = 'eastus'
$VMSize = 'Standard_D32ads_v5'
$VMSize = 'Standard_D32ds_v5'
$ProtoVMName = 'PROTOTYPE'
$ImagePublisher = 'MicrosoftWindowsServer'
$ImageOffer = 'WindowsServer'
Expand Down
2 changes: 1 addition & 1 deletion azure-devops/provision-image.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ if ([string]::IsNullOrEmpty($AdminUserPassword)) {
$PsExecPath = Join-Path $ExtractedPsToolsPath 'PsExec64.exe'

# https://github.com/PowerShell/PowerShell/releases/latest
$PowerShellZipUrl = 'https://github.com/PowerShell/PowerShell/releases/download/v7.3.4/PowerShell-7.3.4-win-x64.zip'
$PowerShellZipUrl = 'https://github.com/PowerShell/PowerShell/releases/download/v7.3.5/PowerShell-7.3.5-win-x64.zip'
Write-Host "Downloading: $PowerShellZipUrl"
$ExtractedPowerShellPath = DownloadAndExtractZip -Url $PowerShellZipUrl
$PwshPath = Join-Path $ExtractedPowerShellPath 'pwsh.exe'
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variables:
benchmarkBuildOutputLocation: 'D:\benchmark'

pool:
name: 'StlBuild-2023-06-13T1913-Pool'
name: 'StlBuild-2023-07-11T1513-Pool'
demands: EnableSpotVM -equals true

pr:
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ function(add_benchmark name)
target_compile_definitions(benchmark-${name} PRIVATE BENCHMARK_STATIC_DEFINE)
endfunction()

add_benchmark(bitset_to_string src/bitset_to_string.cpp)
add_benchmark(locale_classic src/locale_classic.cpp)
add_benchmark(path_lexically_normal src/path_lexically_normal.cpp)
add_benchmark(random_integer_generation src/random_integer_generation.cpp)
add_benchmark(std_copy src/std_copy.cpp)
51 changes: 51 additions & 0 deletions benchmarks/src/bitset_to_string.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <array>
#include <benchmark/benchmark.h>
#include <bit>
#include <bitset>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <random>

using namespace std;

namespace {
const auto random_bits = [] {
mt19937_64 rnd{};
array<uint64_t, 32> arr;
for (auto& d : arr) {
d = rnd();
}
return arr;
}();

template <size_t N, class charT>
void BM_bitset_to_string(benchmark::State& state) {
for (auto _ : state) {
for (const auto& bits : random_bits) {
bitset<N> bs{bits};
benchmark::DoNotOptimize(bs.to_string<charT>());
}
}
}

template <class charT>
void BM_bitset_to_string_large_single(benchmark::State& state) {
const auto large_bitset = bit_cast<bitset<CHAR_BIT * sizeof(random_bits)>>(random_bits);
for (auto _ : state) {
benchmark::DoNotOptimize(large_bitset.to_string<charT>());
}
}
} // namespace

BENCHMARK(BM_bitset_to_string<15, char>);
BENCHMARK(BM_bitset_to_string<64, char>);
BENCHMARK(BM_bitset_to_string_large_single<char>);
BENCHMARK(BM_bitset_to_string<7, wchar_t>);
BENCHMARK(BM_bitset_to_string<64, wchar_t>);
BENCHMARK(BM_bitset_to_string_large_single<wchar_t>);

BENCHMARK_MAIN();
29 changes: 29 additions & 0 deletions benchmarks/src/path_lexically_normal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <benchmark/benchmark.h>
#include <filesystem>
#include <string_view>

namespace {
void BM_lexically_normal(benchmark::State& state) {
using namespace std::literals;
static constexpr std::wstring_view args[5]{
LR"(X:DriveRelative)"sv,
LR"(\\server\\\share)"sv,
LR"(STL/.github/workflows/../..)"sv,
LR"(C:\Program Files\Azure Data Studio\resources\app\extensions\bat\snippets\batchfile.code-snippets)"sv,
LR"(/\server/\share/\a/\b/\c/\./\./\d/\../\../\../\../\../\../\../\other/x/y/z/.././..\meow.txt)"sv,
};

const auto index = state.range(0);
const std::filesystem::path p(args[index]);
for (auto _ : state) {
benchmark::DoNotOptimize(p.lexically_normal());
}
}
} // namespace

BENCHMARK(BM_lexically_normal)->DenseRange(0, 4, 1);

BENCHMARK_MAIN();
20 changes: 10 additions & 10 deletions stl/inc/__msvc_bit_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ _INLINE_VAR constexpr int _Unsigned_integer_digits = sizeof(_UInt) * CHAR_BIT;
// see "Hacker's Delight" section 5-3
template <class _Ty>
_NODISCARD constexpr int _Countl_zero_fallback(_Ty _Val) noexcept {
_Ty _Yy = 0;
_Ty _Yx = 0;

unsigned int _Nn = _Unsigned_integer_digits<_Ty>;
unsigned int _Cc = _Unsigned_integer_digits<_Ty> / 2;
unsigned int _Nx = _Unsigned_integer_digits<_Ty>;
unsigned int _Cx = _Unsigned_integer_digits<_Ty> / 2;
do {
_Yy = static_cast<_Ty>(_Val >> _Cc);
if (_Yy != 0) {
_Nn -= _Cc;
_Val = _Yy;
_Yx = static_cast<_Ty>(_Val >> _Cx);
if (_Yx != 0) {
_Nx -= _Cx;
_Val = _Yx;
}
_Cc >>= 1;
} while (_Cc != 0);
return static_cast<int>(_Nn) - static_cast<int>(_Val);
_Cx >>= 1;
} while (_Cx != 0);
return static_cast<int>(_Nx) - static_cast<int>(_Val);
}

#if !defined(_M_CEE_PURE) && !defined(__CUDACC__) && !defined(__INTEL_COMPILER)
Expand Down
32 changes: 27 additions & 5 deletions stl/inc/__msvc_chrono.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,18 +666,37 @@ namespace chrono {
using time_point = _CHRONO time_point<steady_clock>;
static constexpr bool is_steady = true;

#if defined(_M_ARM) || defined(_M_ARM64) // vvv ARM or ARM64 arch vvv
#define _LIKELY_ARM_ARM64 _LIKELY
#define _LIKELY_X86_X64
#elif defined(_M_IX86) || defined(_M_X64) // ^^^ ARM or ARM64 arch / x86 or x64 arch vvv
#define _LIKELY_ARM_ARM64
#define _LIKELY_X86_X64 _LIKELY
#else // ^^^ x86 or x64 arch / other arch vvv
#define _LIKELY_ARM_ARM64
#define _LIKELY_X86_X64
#endif // ^^^ other arch ^^^
_NODISCARD static time_point now() noexcept { // get current time
const long long _Freq = _Query_perf_frequency(); // doesn't change after system boot
const long long _Ctr = _Query_perf_counter();
static_assert(period::num == 1, "This assumes period::num == 1.");
// 10 MHz is a very common QPC frequency on modern PCs. Optimizing for
// this specific frequency can double the performance of this function by
// avoiding the expensive frequency conversion path.
constexpr long long _TenMHz = 10'000'000;
if (_Freq == _TenMHz) {
// The compiler recognizes the constants for frequency and time period and uses shifts and
// multiplies instead of divides to calculate the nanosecond value.
constexpr long long _TenMHz = 10'000'000;
constexpr long long _TwentyFourMHz = 24'000'000;
// clang-format off
if (_Freq == _TenMHz) _LIKELY_X86_X64 {
// 10 MHz is a very common QPC frequency on modern x86/x64 PCs. Optimizing for
// this specific frequency can double the performance of this function by
// avoiding the expensive frequency conversion path.
static_assert(period::den % _TenMHz == 0, "It should never fail.");
constexpr long long _Multiplier = period::den / _TenMHz;
return time_point(duration(_Ctr * _Multiplier));
} else if (_Freq == _TwentyFourMHz) _LIKELY_ARM_ARM64 {
// 24 MHz is a common frequency on ARM/ARM64, including cases where it emulates x86/x64.
const long long _Whole = (_Ctr / _TwentyFourMHz) * period::den;
const long long _Part = (_Ctr % _TwentyFourMHz) * period::den / _TwentyFourMHz;
return time_point(duration(_Whole + _Part));
} else {
// Instead of just having "(_Ctr * period::den) / _Freq",
// the algorithm below prevents overflow when _Ctr is sufficiently large.
Expand All @@ -688,7 +707,10 @@ namespace chrono {
const long long _Part = (_Ctr % _Freq) * period::den / _Freq;
return time_point(duration(_Whole + _Part));
}
// clang-format on
}
#undef _LIKELY_ARM_ARM64
#undef _LIKELY_X86_X64
};

_EXPORT_STD using high_resolution_clock = steady_clock;
Expand Down
25 changes: 11 additions & 14 deletions stl/inc/__msvc_int128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,14 @@ _STD_BEGIN
#if defined(_M_X64) && !defined(_M_ARM64EC) && !defined(_M_CEE_PURE) && !defined(__CUDACC__) \
&& !defined(__INTEL_COMPILER)
#define _STL_128_INTRINSICS 1
#ifdef __clang__
#define _STL_128_ADD_SUB_INTRINSICS 0 // clang doesn't have _addcarry_u64 / _subborrow_u64
#define _STL_128_DIV_INTRINSICS 0 // clang doesn't have _udiv128 / _div128
#else // ^^^ Clang / other compilers vvv
#define _STL_128_ADD_SUB_INTRINSICS 1
#define _STL_128_DIV_INTRINSICS 1
#endif // ^^^ other compilers ^^^
#ifdef __clang__ // clang doesn't have _udiv128 / _div128
#define _STL_128_DIV_INTRINSICS 0
#else // ^^^ Clang / other vvv
#define _STL_128_DIV_INTRINSICS 1
#endif // ^^^ detect _udiv128 / _div128 ^^^
#else // ^^^ intrinsics available / intrinsics unavailable vvv
#define _STL_128_INTRINSICS 0
#define _STL_128_ADD_SUB_INTRINSICS 0
#define _STL_128_DIV_INTRINSICS 0
#define _STL_128_INTRINSICS 0
#define _STL_128_DIV_INTRINSICS 0
#endif // ^^^ intrinsics unavailable ^^^

template <class _Ty>
Expand Down Expand Up @@ -132,11 +129,11 @@ struct
static constexpr unsigned char _AddCarry64(
unsigned char _Carry, uint64_t _Left, uint64_t _Right, uint64_t& _Result) noexcept {
// _STL_INTERNAL_CHECK(_Carry < 2);
#if _STL_128_ADD_SUB_INTRINSICS
#if _STL_128_INTRINSICS
if (!_Is_constant_evaluated()) {
return _addcarry_u64(_Carry, _Left, _Right, &_Result);
}
#endif // _STL_128_ADD_SUB_INTRINSICS
#endif // _STL_128_INTRINSICS

const uint64_t _Sum = _Left + _Right + _Carry;
_Result = _Sum;
Expand All @@ -146,11 +143,11 @@ struct
static constexpr unsigned char _SubBorrow64(
unsigned char _Carry, uint64_t _Left, uint64_t _Right, uint64_t& _Result) noexcept {
// _STL_INTERNAL_CHECK(_Carry < 2);
#if _STL_128_ADD_SUB_INTRINSICS
#if _STL_128_INTRINSICS
if (!_Is_constant_evaluated()) {
return _subborrow_u64(_Carry, _Left, _Right, &_Result);
}
#endif // _STL_128_ADD_SUB_INTRINSICS
#endif // _STL_128_INTRINSICS

const auto _Difference = _Left - _Right - _Carry;
_Result = _Difference;
Expand Down
24 changes: 18 additions & 6 deletions stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new

// TRANSITION, non-_Ugly attribute tokens
#pragma push_macro("msvc")
#pragma push_macro("lifetimebound")
#undef msvc
#undef lifetimebound

#if _USE_STD_VECTOR_ALGORITHMS

_EXTERN_C
Expand Down Expand Up @@ -10003,8 +10009,9 @@ namespace ranges {
#endif // _HAS_CXX17

_EXPORT_STD template <class _Ty, class _Pr>
_NODISCARD constexpr pair<const _Ty&, const _Ty&> minmax(const _Ty& _Left, const _Ty& _Right, _Pr _Pred) noexcept(
noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ {
_NODISCARD constexpr pair<const _Ty&, const _Ty&> minmax(const _Ty& _Left _MSVC_LIFETIMEBOUND,
const _Ty& _Right _MSVC_LIFETIMEBOUND,
_Pr _Pred) noexcept(noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ {
// return pair(leftmost/smaller, rightmost/larger) of _Left and _Right
if (_DEBUG_LT_PRED(_Pred, _Right, _Left)) {
return {_Right, _Left};
Expand All @@ -10021,8 +10028,8 @@ _NODISCARD constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist, _Pr _Pr
}

_EXPORT_STD template <class _Ty>
_NODISCARD constexpr pair<const _Ty&, const _Ty&> minmax(const _Ty& _Left, const _Ty& _Right) noexcept(
noexcept(_Right < _Left)) /* strengthened */ {
_NODISCARD constexpr pair<const _Ty&, const _Ty&> minmax(const _Ty& _Left _MSVC_LIFETIMEBOUND,
const _Ty& _Right _MSVC_LIFETIMEBOUND) noexcept(noexcept(_Right < _Left)) /* strengthened */ {
// return pair(leftmost/smaller, rightmost/larger) of _Left and _Right
if (_Right < _Left) {
_STL_ASSERT(!(_Left < _Right), "invalid comparator");
Expand All @@ -10049,8 +10056,8 @@ namespace ranges {

template <class _Ty, class _Pj = identity,
indirect_strict_weak_order<projected<const _Ty*, _Pj>> _Pr = ranges::less>
_NODISCARD constexpr minmax_result<const _Ty&> operator()(
const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const {
_NODISCARD constexpr minmax_result<const _Ty&> operator()(const _Ty& _Left _MSVC_LIFETIMEBOUND,
const _Ty& _Right _MSVC_LIFETIMEBOUND, _Pr _Pred = {}, _Pj _Proj = {}) const {
if (_STD invoke(_Pred, _STD invoke(_Proj, _Right), _STD invoke(_Proj, _Left))) {
return {_Right, _Left};
} else {
Expand Down Expand Up @@ -10673,6 +10680,11 @@ namespace ranges {
#endif // _HAS_CXX17

_STD_END

// TRANSITION, non-_Ugly attribute tokens
#pragma pop_macro("lifetimebound")
#pragma pop_macro("msvc")

#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/array
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ public:

conditional_t<disjunction_v<is_default_constructible<_Ty>, _Is_implicitly_default_constructible<_Ty>>, _Ty,
_Empty_array_element>
_Elems[1];
_Elems[1]{};

private:
[[noreturn]] static void _Xran() {
Expand Down
Loading