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
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"editor.formatOnSave": true,
"files.associations": {
".clang-format": "yaml",
"header-units.json": "jsonc",
"**/stl/inc/**": "cpp"
},
"files.eol": "\r\n",
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (NOT DEFINED CMAKE_TOOLCHAIN_FILE AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/vcpkg
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
endif()

cmake_minimum_required(VERSION 3.18)
cmake_minimum_required(VERSION 3.19)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
project(msvc_standard_libraries LANGUAGES CXX)

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem
The STL uses boost-math headers to provide P0226R1 Mathematical Special Functions. We recommend using [vcpkg][] to
acquire this dependency.

1. Install Visual Studio 2019 16.9 Preview 2 or later.
1. Install Visual Studio 2019 16.9 Preview 3 or later.
* 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.
* Otherwise, install [CMake][] 3.18 or later, and [Ninja][] 1.8.2 or later.
* Otherwise, install [CMake][] 3.19 or later, and [Ninja][] 1.10.2 or later.
2. Open Visual Studio, and choose the "Clone or check out code" option. Enter the URL of this repository,
`https://github.com/microsoft/STL`.
3. Open a terminal in the IDE with `` Ctrl + ` `` (by default) or press on "View" in the top bar, and then "Terminal".
Expand All @@ -158,10 +158,10 @@ acquire this dependency.

# How To Build With A Native Tools Command Prompt

1. Install Visual Studio 2019 16.9 Preview 2 or later.
1. Install Visual Studio 2019 16.9 Preview 3 or later.
* 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.
* Otherwise, install [CMake][] 3.18 or later, and [Ninja][] 1.8.2 or later.
* Otherwise, install [CMake][] 3.19 or later, and [Ninja][] 1.10.2 or later.
2. Open a command prompt.
3. Change directories to a location where you'd like a clone of this STL repository.
4. `git clone https://github.com/microsoft/STL`
Expand Down Expand Up @@ -234,7 +234,7 @@ C:\Users\username\Desktop>dumpbin /IMPORTS .\example.exe | findstr msvcp
# How To Run The Tests With A Native Tools Command Prompt

1. Follow either [How To Build With A Native Tools Command Prompt][] or [How To Build With The Visual Studio IDE][].
2. Acquire [Python][] 3.9 or newer and have it on the `PATH` (or run it directly using its absolute or relative path).
2. Acquire [Python][] 3.9.1 or newer and have it on the `PATH` (or run it directly using its absolute or relative path).
3. Have LLVM's `bin` directory on the `PATH` (so `clang-cl.exe` is available).
* We recommend selecting "C++ Clang tools for Windows" in the VS Installer. This will automatically add LLVM to the
`PATH` of the x86 and x64 Native Tools Command Prompts, and will ensure that you're using a supported version.
Expand Down
3 changes: 3 additions & 0 deletions azure-devops/create-vmss.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ or are running from Azure Cloud Shell.

$ErrorActionPreference = 'Stop'

# https://aka.ms/azps-changewarnings
$Env:SuppressAzurePowerShellBreakingChangeWarnings = 'true'

$Location = 'westus2'
$Prefix = 'StlBuild-' + (Get-Date -Format 'yyyy-MM-dd')
$VMSize = 'Standard_D32as_v4'
Expand Down
65 changes: 55 additions & 10 deletions azure-devops/provision-image.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,75 @@ Function Get-TempFilePath {
return Join-Path $tempPath $tempName
}

<#
.SYNOPSIS
Downloads and extracts a ZIP file to a newly created temporary subdirectory.

.DESCRIPTION
DownloadAndExtractZip returns a path containing the extracted contents.

.PARAMETER Url
The URL of the ZIP file to download.
#>
Function DownloadAndExtractZip {
Param(
[String]$Url
)

if ([String]::IsNullOrWhiteSpace($Url)) {
throw 'Missing Url'
}

$ZipPath = Get-TempFilePath -Extension 'zip'
& curl.exe -L -o $ZipPath -s -S $Url
$TempSubdirPath = Get-TempFilePath -Extension 'dir'
Expand-Archive -Path $ZipPath -DestinationPath $TempSubdirPath -Force

return $TempSubdirPath
}

$TranscriptPath = 'C:\provision-image-transcript.txt'

if ([string]::IsNullOrEmpty($AdminUserPassword)) {
Start-Transcript -Path $TranscriptPath
Start-Transcript -Path $TranscriptPath -UseMinimalHeader
} else {
Write-Host 'AdminUser password supplied; switching to AdminUser.'
$PsExecPath = Get-TempFilePath -Extension 'exe'
Write-Host "Downloading psexec to: $PsExecPath"
& curl.exe -L -o $PsExecPath -s -S https://live.sysinternals.com/PsExec64.exe

# https://docs.microsoft.com/en-us/sysinternals/downloads/psexec
$PsToolsZipUrl = 'https://download.sysinternals.com/files/PSTools.zip'
Write-Host "Downloading: $PsToolsZipUrl"
$ExtractedPsToolsPath = DownloadAndExtractZip -Url $PsToolsZipUrl
$PsExecPath = Join-Path $ExtractedPsToolsPath 'PsExec64.exe'

# https://github.com/PowerShell/PowerShell/releases/latest
$PowerShellZipUrl = 'https://github.com/PowerShell/PowerShell/releases/download/v7.1.1/PowerShell-7.1.1-win-x64.zip'
Write-Host "Downloading: $PowerShellZipUrl"
$ExtractedPowerShellPath = DownloadAndExtractZip -Url $PowerShellZipUrl
$PwshPath = Join-Path $ExtractedPowerShellPath 'pwsh.exe'

$PsExecArgs = @(
'-u',
'AdminUser',
'-p',
$AdminUserPassword,
'AdminUserPassword_REDACTED',
'-accepteula',
'-i',
'-h',
'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe',
$PwshPath,
'-ExecutionPolicy',
'Unrestricted',
'-File',
$PSCommandPath
)

Write-Host "Executing: $PsExecPath $PsExecArgs"
$PsExecArgs[3] = $AdminUserPassword

$proc = Start-Process -FilePath $PsExecPath -ArgumentList $PsExecArgs -Wait -PassThru
Write-Host 'Reading transcript...'
Get-Content -Path $TranscriptPath
Write-Host 'Cleaning up...'
Remove-Item $PsExecPath
Remove-Item -Recurse -Path $ExtractedPsToolsPath
Remove-Item -Recurse -Path $ExtractedPowerShellPath
exit $proc.ExitCode
}

Expand All @@ -100,7 +139,7 @@ $Workloads = @(
$ReleaseInPath = 'Preview'
$Sku = 'Enterprise'
$VisualStudioBootstrapperUrl = 'https://aka.ms/vs/16/pre/vs_enterprise.exe'
$PythonUrl = 'https://www.python.org/ftp/python/3.9.0/python-3.9.0-amd64.exe'
$PythonUrl = 'https://www.python.org/ftp/python/3.9.1/python-3.9.1-amd64.exe'

# https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk
$WindowsDriverKitUrl = 'https://go.microsoft.com/fwlink/?linkid=2128854'
Expand Down Expand Up @@ -315,7 +354,7 @@ Function PipInstall {

try {
Write-Host "Installing or upgrading $Package..."
python.exe -m pip install --upgrade $Package
python.exe -m pip install --progress-bar off --upgrade $Package
Write-Host "Done installing or upgrading $Package."
}
catch {
Expand Down Expand Up @@ -358,3 +397,9 @@ Write-Host 'Finished updating PATH!'

PipInstall pip
PipInstall psutil

# https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/bcdedit--set#verification-settings
Write-Host 'Enabling test-signed kernel-mode drivers...'
bcdedit /set testsigning on

Write-Host 'Done!'
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
variables:
tmpDir: 'D:\Temp'

pool: 'StlBuild-2020-12-08-1'
pool: 'StlBuild-2021-01-20-2'

stages:
- stage: Code_Format
Expand Down
1 change: 1 addition & 0 deletions stl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ set(HEADERS
${CMAKE_CURRENT_LIST_DIR}/inc/future
${CMAKE_CURRENT_LIST_DIR}/inc/hash_map
${CMAKE_CURRENT_LIST_DIR}/inc/hash_set
${CMAKE_CURRENT_LIST_DIR}/inc/header-units.json
${CMAKE_CURRENT_LIST_DIR}/inc/initializer_list
${CMAKE_CURRENT_LIST_DIR}/inc/iomanip
${CMAKE_CURRENT_LIST_DIR}/inc/ios
Expand Down
1 change: 1 addition & 0 deletions stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -4174,6 +4174,7 @@ namespace ranges {

for (;; ++_Current) {
if (++_First == _Last) {
++_Current;
return {_STD move(_Current), _STD move(_First)};
}

Expand Down
9 changes: 9 additions & 0 deletions stl/inc/future
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,9 @@ class future : public _State_manager<_Ty> {
using _Mybase = _State_manager<_Ty>;

public:
static_assert(!is_array_v<_Ty> && is_object_v<_Ty> && is_destructible_v<_Ty>,
"T in future<T> must meet the Cpp17Destructible requirements (N4878 [futures.unique.future]/4).");

future() noexcept {}

future(future&& _Other) noexcept : _Mybase(_STD move(_Other), true) {}
Expand Down Expand Up @@ -972,6 +975,9 @@ class shared_future : public _State_manager<_Ty> {
using _Mybase = _State_manager<_Ty>;

public:
static_assert(!is_array_v<_Ty> && is_object_v<_Ty> && is_destructible_v<_Ty>,
"T in shared_future<T> must meet the Cpp17Destructible requirements (N4878 [futures.shared.future]/4).");

shared_future() noexcept {}

shared_future(const shared_future& _Other) noexcept : _Mybase(_Other) {}
Expand Down Expand Up @@ -1139,6 +1145,9 @@ private:
template <class _Ty>
class promise { // class that defines an asynchronous provider that holds a value
public:
static_assert(!is_array_v<_Ty> && is_object_v<_Ty> && is_destructible_v<_Ty>,
"T in promise<T> must meet the Cpp17Destructible requirements (N4878 [futures.promise]/1).");

promise() : _MyPromise(new _Associated_state<_Ty>) {}

template <class _Alloc>
Expand Down
149 changes: 149 additions & 0 deletions stl/inc/header-units.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

{
"Version": "1.0",
"BuildAsHeaderUnits": [
// "__msvc_all_public_headers.hpp", // for testing, not production
"__msvc_system_error_abi.hpp",
"algorithm",
"any",
"array",
"atomic",
"barrier",
"bit",
"bitset",
// "cassert", // design is permanently incompatible with header units
// "ccomplex", // removed in C++20
"cctype",
"cerrno",
"cfenv",
"cfloat",
"charconv",
"chrono",
"cinttypes",
// "ciso646", // removed in C++20
"climits",
"clocale",
"cmath",
"codecvt",
"compare",
"complex",
"concepts",
"condition_variable",
"coroutine",
"csetjmp",
"csignal",
// "cstdalign", // removed in C++20
"cstdarg",
// "cstdbool", // removed in C++20
"cstddef",
"cstdint",
"cstdio",
"cstdlib",
"cstring",
// "ctgmath", // removed in C++20
"ctime",
"cuchar",
"cwchar",
"cwctype",
"deque",
"exception",
"execution",
"filesystem",
"forward_list",
"fstream",
"functional",
"future",
// "hash_map", // non-Standard, will be removed soon
// "hash_set", // non-Standard, will be removed soon
"initializer_list",
"iomanip",
"ios",
"iosfwd",
"iostream",
"iso646.h",
"istream",
"iterator",
"latch",
"limits",
"list",
"locale",
"map",
"memory",
"memory_resource",
"mutex",
"new",
"numbers",
"numeric",
"optional",
"ostream",
"queue",
"random",
"ranges",
"ratio",
"regex",
"scoped_allocator",
"semaphore",
"set",
"shared_mutex",
"span",
"sstream",
"stack",
"stdexcept",
"stop_token",
"streambuf",
"string",
"string_view",
"strstream",
"system_error",
"thread",
"tuple",
"type_traits",
"typeindex",
"typeinfo",
"unordered_map",
"unordered_set",
"use_ansi.h",
"utility",
"valarray",
"variant",
"vector",
"version",
"xatomic.h",
"xatomic_wait.h",
"xbit_ops.h",
"xcall_once.h",
"xcharconv.h",
"xcharconv_ryu.h",
"xcharconv_ryu_tables.h",
"xerrc.h",
"xfacet",
"xfilesystem_abi.h",
"xhash",
"xiosbase",
// "xkeycheck.h", // internal header, provides no machinery, scans for macroized keywords only
"xlocale",
"xlocbuf",
"xlocinfo",
"xlocinfo.h",
"xlocmes",
"xlocmon",
"xlocnum",
"xloctime",
"xmemory",
"xnode_handle.h",
"xpolymorphic_allocator.h",
"xsmf_control.h",
"xstddef",
"xstring",
"xthreads.h",
"xtimec.h",
"xtr1common",
"xtree",
"xutility",
"ymath.h",
"yvals.h",
"yvals_core.h"
]
}
11 changes: 8 additions & 3 deletions stl/inc/limits
Original file line number Diff line number Diff line change
Expand Up @@ -1058,9 +1058,14 @@ _NODISCARD int _Checked_x86_x64_countr_zero(const _Ty _Val) noexcept {
constexpr _Ty _Max = (numeric_limits<_Ty>::max)();

#ifndef __AVX2__
const bool _Definitely_have_tzcnt = __isa_available >= __ISA_AVAILABLE_AVX2;
if (!_Definitely_have_tzcnt && _Val == 0) {
return _Digits;
// Because the widening done below will always give a non-0 value, checking for tzcnt
// is not required for 8-bit and 16-bit since the only difference in behavior between
// bsf and tzcnt is when the value is 0.
if constexpr (_Digits > 16) {
const bool _Definitely_have_tzcnt = __isa_available >= __ISA_AVAILABLE_AVX2;
if (!_Definitely_have_tzcnt && _Val == 0) {
return _Digits;
}
}
#endif // __AVX2__

Expand Down
Loading