Skip to content

Commit 5f31ec5

Browse files
committed
Merge remote-tracking branch 'upstream/main' into copycats
# Conflicts: # benchmarks/src/unique.cpp # stl/inc/algorithm # stl/src/vector_algorithms.cpp
2 parents 7a1de3d + f2a2933 commit 5f31ec5

File tree

83 files changed

+3090
-665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3090
-665
lines changed

.github/workflows/update-status-chart.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup Node.js
2121
uses: actions/setup-node@v4
2222
with:
23-
node-version: ">=22.2.0"
23+
node-version: ">=23.9.0"
2424
- name: Install Packages
2525
run: |
2626
npm ci

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ issue. The [bug tag][] and [enhancement tag][] are being populated.
5858

5959
# Goals
6060

61-
We're implementing the latest C++ Working Draft, currently [N5001][], which will eventually become the next C++
61+
We're implementing the latest C++ Working Draft, currently [N5008][], which will eventually become the next C++
6262
International Standard. The terms Working Draft (WD) and Working Paper (WP) are interchangeable; we often
6363
informally refer to these drafts as "the Standard" while being aware of the difference. (There are other relevant
6464
Standards; for example, supporting `/std:c++14` and `/std:c++17` involves understanding how the C++14 and C++17
@@ -141,7 +141,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem
141141

142142
# How To Build With The Visual Studio IDE
143143

144-
1. Install Visual Studio 2022 17.14 Preview 1 or later.
144+
1. Install Visual Studio 2022 17.14 Preview 2 or later.
145145
* Select "Windows 11 SDK (10.0.22621.0)" in the VS Installer.
146146
* Select "MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest)" in the VS Installer
147147
if you would like to build the ARM64/ARM64EC target.
@@ -160,7 +160,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem
160160

161161
# How To Build With A Native Tools Command Prompt
162162

163-
1. Install Visual Studio 2022 17.14 Preview 1 or later.
163+
1. Install Visual Studio 2022 17.14 Preview 2 or later.
164164
* Select "Windows 11 SDK (10.0.22621.0)" in the VS Installer.
165165
* Select "MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest)" in the VS Installer
166166
if you would like to build the ARM64/ARM64EC target.
@@ -379,8 +379,8 @@ steps. Let's assume we want to debug a new feature with tests located in `tests\
379379

380380
As always, build the STL from your branch and run the tests:
381381
```
382-
C:\STL\out\x64> ninja
383-
C:\STL\out\x64> python tests\utils\stl-lit\stl-lit.py -v C:\STL\tests\std\tests\GH_XXXX_meow
382+
C:\Dev\STL\out\x64> ninja
383+
C:\Dev\STL\out\x64> python tests\utils\stl-lit\stl-lit.py -v C:\Dev\STL\tests\std\tests\GH_XXXX_meow
384384
```
385385

386386
Let's assume one of the tests fails an assert and we want to debug that configuration. `stl-lit` will conveniently print
@@ -390,23 +390,23 @@ provide debug symbols: `/Zi /Fdbark.pdb`.
390390
You can replace `bark` with any descriptive name you like. Add these before the `"-link"` option in the command line
391391
and recompile. Example:
392392
```
393-
C:\STL\out\x64>cl "C:\STL\tests\std\tests\GH_XXXX_meow\test.cpp" [... more arguments ...]
394-
"-FeC:\STL\out\x64\tests\std\tests\GH_XXXX_meow\Output\02\GH_XXXX_meow.exe" /Zi /Fdbark.pdb "-link"
393+
C:\Dev\STL\out\x64>cl "C:\Dev\STL\tests\std\tests\GH_XXXX_meow\test.cpp" [... more arguments ...]
394+
"-FeC:\Dev\STL\out\x64\tests\std\tests\GH_XXXX_meow\Output\02\GH_XXXX_meow.exe" /Zi /Fdbark.pdb "-link"
395395
[... more arguments ...]
396396
```
397397

398398
You can now start debugging the test via:
399399
```
400-
devenv "C:\STL\out\x64\tests\std\tests\GH_XXXX_meow\Output\02\GH_XXXX_meow.exe"
401-
"C:\STL\tests\std\tests\GH_XXXX_meow\test.cpp"
400+
devenv "C:\Dev\STL\out\x64\tests\std\tests\GH_XXXX_meow\Output\02\GH_XXXX_meow.exe"
401+
"C:\Dev\STL\tests\std\tests\GH_XXXX_meow\test.cpp"
402402
```
403403

404404
However, this might not work right away, as Visual Studio may complain about a missing `msvcp140_oss.dll`. The reason
405405
is that the STL builds those and other DLLs itself and we should under no circumstances overwrite the installed ones.
406406
If you are testing one of the configurations with dynamic linkage (`/MD` or `/MDd`) the easiest solution is to add the
407407
build folder to your path:
408408
```
409-
set PATH=C:\STL\out\x64\out\bin\amd64;%PATH%
409+
set PATH=C:\Dev\STL\out\x64\out\bin\amd64;%PATH%
410410
```
411411

412412
## Running Tests With Address Sanitizer (ASan)
@@ -568,7 +568,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
568568
[LWG issues]: https://cplusplus.github.io/LWG/lwg-toc.html
569569
[LWG tag]: https://github.com/microsoft/STL/issues?q=is%3Aopen+is%3Aissue+label%3ALWG
570570
[Microsoft Open Source Code of Conduct]: https://opensource.microsoft.com/codeofconduct/
571-
[N5001]: https://wg21.link/N5001
571+
[N5008]: https://wg21.link/N5008
572572
[NOTICE.txt]: NOTICE.txt
573573
[Ninja]: https://ninja-build.org
574574
[STL-CI-badge]: https://dev.azure.com/vclibs/STL/_apis/build/status%2FSTL-CI?branchName=main "STL-CI"

azure-devops/checkout-self.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ steps:
1111
submodules: false
1212
fetchDepth: 1
1313
fetchTags: false
14+
retryCountOnTaskFailure: 4
1415
- script: |
1516
git clean --quiet -x -d -f -f
1617
displayName: 'Clean after checkout'

azure-devops/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
variables:
77
- name: poolName
8-
value: 'StlBuild-2025-02-15T0137-Pool'
8+
value: 'StlBuild-2025-03-11T1203-Pool'
99
readonly: true
1010
- name: poolDemands
1111
value: 'EnableSpotVM -equals false'

azure-devops/create-1es-hosted-pool.ps1

+80-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $ImageSku = '2025-datacenter-azure-edition'
2222

2323
$LogFile = '1es-hosted-pool.log'
2424
$ProgressActivity = 'Preparing STL CI pool'
25-
$TotalProgress = 26
25+
$TotalProgress = 38
2626
$CurrentProgress = 1
2727

2828
<#
@@ -103,20 +103,54 @@ $AdminPWSecure = New-Password
103103
$Credential = New-Object System.Management.Automation.PSCredential ('AdminUser', $AdminPWSecure)
104104

105105
####################################################################################################
106-
Display-ProgressBar -Status 'Creating virtual network'
106+
Display-ProgressBar -Status 'Creating public IP address'
107+
108+
$PublicIpAddressName = $ResourceGroupName + '-PublicIpAddress'
109+
$PublicIpAddress = New-AzPublicIpAddress `
110+
-Name $PublicIpAddressName `
111+
-ResourceGroupName $ResourceGroupName `
112+
-Location $Location `
113+
-Sku 'Standard' `
114+
-AllocationMethod 'Static'
115+
116+
####################################################################################################
117+
Display-ProgressBar -Status 'Creating NAT gateway'
118+
119+
$NatGatewayName = $ResourceGroupName + '-NatGateway'
120+
$NatGateway = New-AzNatGateway `
121+
-Name $NatGatewayName `
122+
-ResourceGroupName $ResourceGroupName `
123+
-Location $Location `
124+
-IdleTimeoutInMinutes 10 `
125+
-Sku 'Standard' `
126+
-PublicIpAddress $PublicIpAddress
127+
128+
####################################################################################################
129+
Display-ProgressBar -Status 'Creating network security group'
107130

108131
$NetworkSecurityGroupName = $ResourceGroupName + '-NetworkSecurity'
109132
$NetworkSecurityGroup = New-AzNetworkSecurityGroup `
110133
-Name $NetworkSecurityGroupName `
111134
-ResourceGroupName $ResourceGroupName `
112135
-Location $Location
113136

137+
####################################################################################################
138+
Display-ProgressBar -Status 'Creating virtual network subnet config'
139+
140+
# TRANSITION, 2025-09-30: "On September 30, 2025, default outbound access for new deployments will be retired."
141+
# https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/default-outbound-access
142+
# We're using `-DefaultOutboundAccess $false` to opt-in early.
114143
$SubnetName = $ResourceGroupName + '-Subnet'
115144
$Subnet = New-AzVirtualNetworkSubnetConfig `
116145
-Name $SubnetName `
117146
-AddressPrefix '10.0.0.0/16' `
147+
-DefaultOutboundAccess $false `
148+
-NatGateway $NatGateway `
118149
-NetworkSecurityGroup $NetworkSecurityGroup
119150

151+
####################################################################################################
152+
Display-ProgressBar -Status 'Creating virtual network'
153+
120154
$VirtualNetworkName = $ResourceGroupName + '-Network'
121155
$VirtualNetwork = New-AzVirtualNetwork `
122156
-Name $VirtualNetworkName `
@@ -136,7 +170,7 @@ $Nic = New-AzNetworkInterface `
136170
-Subnet $VirtualNetwork.Subnets[0]
137171

138172
####################################################################################################
139-
Display-ProgressBar -Status 'Creating prototype VM'
173+
Display-ProgressBar -Status 'Creating prototype VM config'
140174

141175
# Previously: -Priority 'Spot'
142176
$VM = New-AzVMConfig `
@@ -145,33 +179,51 @@ $VM = New-AzVMConfig `
145179
-DiskControllerType 'NVMe' `
146180
-Priority 'Regular'
147181

182+
####################################################################################################
183+
Display-ProgressBar -Status 'Setting prototype VM OS'
184+
148185
$VM = Set-AzVMOperatingSystem `
149186
-VM $VM `
150187
-Windows `
151188
-ComputerName $ProtoVMName `
152189
-Credential $Credential `
153190
-ProvisionVMAgent
154191

192+
####################################################################################################
193+
Display-ProgressBar -Status 'Adding prototype VM network interface'
194+
155195
$VM = Add-AzVMNetworkInterface `
156196
-VM $VM `
157197
-Id $Nic.Id
158198

199+
####################################################################################################
200+
Display-ProgressBar -Status 'Setting prototype VM source image'
201+
159202
$VM = Set-AzVMSourceImage `
160203
-VM $VM `
161204
-PublisherName $ImagePublisher `
162205
-Offer $ImageOffer `
163206
-Skus $ImageSku `
164207
-Version 'latest'
165208

209+
####################################################################################################
210+
Display-ProgressBar -Status 'Setting prototype VM boot diagnostic'
211+
166212
$VM = Set-AzVMBootDiagnostic `
167213
-VM $VM `
168214
-Disable
169215

216+
####################################################################################################
217+
Display-ProgressBar -Status 'Creating prototype VM'
218+
170219
New-AzVm `
171220
-ResourceGroupName $ResourceGroupName `
172221
-Location $Location `
173222
-VM $VM >> $LogFile
174223

224+
####################################################################################################
225+
Display-ProgressBar -Status 'Getting prototype VM OS disk name'
226+
175227
$VM = Get-AzVM `
176228
-ResourceGroupName $ResourceGroupName `
177229
-Name $ProtoVMName
@@ -350,25 +402,41 @@ Remove-AzDisk `
350402
Display-ProgressBar -Status 'Deleting unused network interface'
351403

352404
Remove-AzNetworkInterface `
353-
-ResourceGroupName $ResourceGroupName `
354-
-Name $NicName `
355-
-Force >> $LogFile
405+
-ResourceGroupName $ResourceGroupName `
406+
-Name $NicName `
407+
-Force >> $LogFile
356408

357409
####################################################################################################
358410
Display-ProgressBar -Status 'Deleting unused virtual network'
359411

360412
Remove-AzVirtualNetwork `
361-
-ResourceGroupName $ResourceGroupName `
362-
-Name $VirtualNetworkName `
363-
-Force >> $LogFile
413+
-ResourceGroupName $ResourceGroupName `
414+
-Name $VirtualNetworkName `
415+
-Force >> $LogFile
364416

365417
####################################################################################################
366418
Display-ProgressBar -Status 'Deleting unused network security group'
367419

368420
Remove-AzNetworkSecurityGroup `
369-
-ResourceGroupName $ResourceGroupName `
370-
-Name $NetworkSecurityGroupName `
371-
-Force >> $LogFile
421+
-ResourceGroupName $ResourceGroupName `
422+
-Name $NetworkSecurityGroupName `
423+
-Force >> $LogFile
424+
425+
####################################################################################################
426+
Display-ProgressBar -Status 'Deleting unused NAT gateway'
427+
428+
Remove-AzNatGateway `
429+
-ResourceGroupName $ResourceGroupName `
430+
-Name $NatGatewayName `
431+
-Force >> $LogFile
432+
433+
####################################################################################################
434+
Display-ProgressBar -Status 'Deleting unused public IP address'
435+
436+
Remove-AzPublicIpAddress `
437+
-ResourceGroupName $ResourceGroupName `
438+
-Name $PublicIpAddressName `
439+
-Force >> $LogFile
372440

373441
####################################################################################################
374442
Write-Progress -Activity $ProgressActivity -Completed

azure-devops/provision-image.ps1

+1-9
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ $PowerShellArgs = @('/quiet', '/norestart')
4646
$PythonUrl = 'https://www.python.org/ftp/python/3.13.2/python-3.13.2-amd64.exe'
4747
$PythonArgs = @('/quiet', 'InstallAllUsers=1', 'PrependPath=1', 'CompileAll=1', 'Include_doc=0')
4848

49-
# TRANSITION, GH-5282: Install only nvcc and cudart, then manually add CUDA to the PATH (see below).
5049
$CudaUrl = 'https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe'
51-
$CudaArgs = @('-s', '-n', 'nvcc_12.4', 'cudart_12.4')
52-
$CudaPath = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\bin'
50+
$CudaArgs = @('-s', '-n')
5351

5452
<#
5553
.SYNOPSIS
@@ -114,12 +112,6 @@ DownloadAndInstall -Name 'CUDA' -Url $CudaUrl -Args $CudaArgs
114112

115113
Write-Host 'Setting environment variables...'
116114

117-
# TRANSITION, GH-5282: Manually add CUDA to the PATH.
118-
# Don't use $Env:PATH here - that's the local path for this running script, captured before we installed anything.
119-
# The machine path was just updated by the installers above.
120-
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
121-
[Environment]::SetEnvironmentVariable('Path', "$machinePath;$CudaPath", 'Machine')
122-
123115
# The STL's PR/CI builds are totally unrepresentative of customer usage.
124116
[Environment]::SetEnvironmentVariable('VSCMD_SKIP_SENDTELEMETRY', '1', 'Machine')
125117

benchmarks/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ function(add_benchmark name)
107107
endfunction()
108108

109109
add_benchmark(adjacent_difference src/adjacent_difference.cpp)
110+
add_benchmark(adjacent_find src/adjacent_find.cpp)
110111
add_benchmark(bitset_from_string src/bitset_from_string.cpp)
111112
add_benchmark(bitset_to_string src/bitset_to_string.cpp)
112113
add_benchmark(efficient_nonlocking_print src/efficient_nonlocking_print.cpp)
@@ -117,12 +118,14 @@ add_benchmark(iota src/iota.cpp)
117118
add_benchmark(locale_classic src/locale_classic.cpp)
118119
add_benchmark(minmax_element src/minmax_element.cpp)
119120
add_benchmark(mismatch src/mismatch.cpp)
121+
add_benchmark(move_only_function src/move_only_function.cpp)
120122
add_benchmark(path_lexically_normal src/path_lexically_normal.cpp)
121123
add_benchmark(priority_queue_push_range src/priority_queue_push_range.cpp)
122124
add_benchmark(random_integer_generation src/random_integer_generation.cpp)
123125
add_benchmark(remove src/remove.cpp)
124126
add_benchmark(replace src/replace.cpp)
125127
add_benchmark(search src/search.cpp)
128+
add_benchmark(search_n src/search_n.cpp)
126129
add_benchmark(std_copy src/std_copy.cpp)
127130
add_benchmark(sv_equal src/sv_equal.cpp)
128131
add_benchmark(swap_ranges src/swap_ranges.cpp)

benchmarks/src/adjacent_find.cpp

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
#include <algorithm>
5+
#include <benchmark/benchmark.h>
6+
#include <cstddef>
7+
#include <cstdint>
8+
#include <cstdlib>
9+
#include <vector>
10+
11+
using namespace std;
12+
13+
enum class AlgType { Std, Rng };
14+
15+
template <AlgType Alg, class T>
16+
void bm(benchmark::State& state) {
17+
const size_t size = static_cast<size_t>(state.range(0));
18+
const size_t pos = static_cast<size_t>(state.range(1));
19+
20+
vector<T> v(size);
21+
22+
for (size_t i = 0; i != size; ++i) {
23+
v[i] = static_cast<T>(i & 3);
24+
}
25+
26+
if (pos == 0 || pos >= size) {
27+
abort();
28+
}
29+
30+
v[pos] = v[pos - 1];
31+
32+
for (auto _ : state) {
33+
benchmark::DoNotOptimize(v);
34+
if constexpr (Alg == AlgType::Std) {
35+
benchmark::DoNotOptimize(adjacent_find(v.begin(), v.end()));
36+
} else {
37+
benchmark::DoNotOptimize(ranges::adjacent_find(v));
38+
}
39+
}
40+
}
41+
42+
void common_args(auto bm) {
43+
bm->ArgPair(2525, 1142);
44+
}
45+
46+
BENCHMARK(bm<AlgType::Std, int8_t>)->Apply(common_args);
47+
BENCHMARK(bm<AlgType::Std, int16_t>)->Apply(common_args);
48+
BENCHMARK(bm<AlgType::Std, int32_t>)->Apply(common_args);
49+
BENCHMARK(bm<AlgType::Std, int64_t>)->Apply(common_args);
50+
51+
BENCHMARK(bm<AlgType::Rng, int8_t>)->Apply(common_args);
52+
BENCHMARK(bm<AlgType::Rng, int16_t>)->Apply(common_args);
53+
BENCHMARK(bm<AlgType::Rng, int32_t>)->Apply(common_args);
54+
BENCHMARK(bm<AlgType::Rng, int64_t>)->Apply(common_args);
55+
56+
BENCHMARK_MAIN();

0 commit comments

Comments
 (0)