Граф коммитов

1180 Коммитов

Автор SHA1 Сообщение Дата
Alex Guteniev f3ca37d67c
Implement atomic_ref (#2, p0019r8) (#843)
Co-authored-by: Billy O'Neal <bion@microsoft.com>
Co-authored-by: Adam Bucior <35536269+AdamBucior@users.noreply.github.com>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
2020-08-12 18:10:46 -07:00
Alex Guteniev f3bbb98e71
Move _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE (#1179) 2020-08-12 12:52:23 -07:00
Casey Carter ae1068e07b
<deque>: Use _Next_iter and _Prev_iter (#1161) 2020-08-12 12:51:26 -07:00
Casey Carter 7f29487be5
Implement ranges::uninitialized_move (#1137) 2020-08-12 12:47:52 -07:00
Casey Carter 4ce746ca4e
Implement ranges::sort (#1127) 2020-08-12 12:45:48 -07:00
statementreply 3224307ff6
<random>: Fix parameter initialization of piecewise_constant_distribution and piecewise_linear_distribution (#1032) 2020-08-12 12:37:36 -07:00
Jonathan Emmett 1680ae7f0e
Remove noexcept from coroutine_handle<>::resume and operator() (#1182) 2020-08-11 15:04:41 -07:00
Billy O'Neal f437e98359
Add DisableThreadLibraryCalls to all satellite DLLs. (#1142) 2020-08-10 23:52:31 -07:00
Hamid Reza Arzaghi 19135668f4
Fix unnecessary self-move-assignments in deque erase(iter, iter) (#1148)
Fixes #1118.
2020-08-09 16:05:27 -07:00
Alex Guteniev 392fb6d857
Cache hardware thread count for <execution> (#1143)
Fixes #1134.

Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Billy O'Neal <bion@microsoft.com>
2020-08-09 15:59:11 -07:00
Alex Guteniev bdf7710249
wait/notify atomic<shared_ptr<T>> (#52, P1644R0) (#1136)
Co-authored-by: Adam Bucior <35536269+AdamBucior@users.noreply.github.com>
2020-08-09 15:38:59 -07:00
Casey Carter af3db68781
partial_sort_copy bugfix (#1088)
Fixes #1086.
2020-08-09 15:28:43 -07:00
Casey Carter eb33f1a1e9
Implement ranges::lexicographical_compare (#1081) 2020-08-09 15:07:00 -07:00
Stephan T. Lavavej d83bc99312
Upgrade toolset to VS 2019 16.8 Preview 1 (#1153)
Fixes #1051.
2020-08-09 14:56:45 -07:00
leejy12 cbfc5272c8
Update _MSVC_STL_UPDATE to August 2020 (#1144) 2020-08-05 00:21:15 -07:00
Stephan T. Lavavej 06c2c54358
Fix build warning "restarting link with /LTCG". (#1140) 2020-08-05 00:17:15 -07:00
Casey Carter 5d00b606b4
Implement ranges::merge (#1101) 2020-08-05 00:09:55 -07:00
Casey Carter 0eb754dedd
Implement ranges::next_permutation and ranges::prev_permutation (#1099) 2020-08-05 00:02:21 -07:00
Casey Carter 622b62a777
Implement ranges::reverse_copy (#1095)
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-08-04 23:51:25 -07:00
Stephan T. Lavavej 12c684bba7
Cleanup std qualification and old bug citations (#1119) 2020-08-01 18:35:54 -07:00
Alex Guteniev e4b75dcd44
Implement std::atomic::wait (#593)
Co-authored-by: Curtis J Bezault <curtbezault@gmail.com>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Co-authored-by: Casey Carter <cartec69@gmail.com>
2020-08-01 17:54:07 -07:00
Billy O'Neal 8ec6b33a92
P1001R2 execution::unseq (#1111)
Resolves #44.
2020-08-01 17:02:51 -07:00
Alex Guteniev 782cd650ec
<bit>: Fix countl_zero to switch between lzcnt and bsr correctly (#1108)
Fixes #1103.
2020-08-01 16:44:01 -07:00
Stephan T. Lavavej 57db210e30
Fix weak_ptr conversions, preserving control blocks for expired objects (#1104)
Fixes #1102.
2020-08-01 16:36:24 -07:00
Casey Carter e2912b6e48
Implement ranges::ssize (#1076) 2020-08-01 16:19:09 -07:00
Casey Carter e58a94505b
Implement ranges::nth_element (#1063) 2020-08-01 16:08:38 -07:00
Michael Schellenberger Costa accaf18978
Modernize ranges::swap_ranges and ranges::distance (#1062)
Co-authored-by: Casey Carter <Casey@Carter.net>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
2020-08-01 16:03:08 -07:00
Michael Schellenberger Costa 1ff3d1ef11
Optimize fill and fill_n for vector<bool> (#879)
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-08-01 15:58:39 -07:00
ArtemSarmini 0381c25b10
<type_traits>: is_function simplification (#460)
Fixes #198.

Co-authored-by: Casey Carter <cacarter@microsoft.com>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-08-01 15:29:40 -07:00
Casey Carter 4e97255b35
Comparison category types become aggregates (#1065)
... for enregistration, to improve performance. Per a suggestion from Statementreply in the discussion at https://github.com/microsoft/STL/pull/1049#discussion_r456298672.
2020-07-29 21:14:13 -07:00
Michael Schellenberger Costa 58a8a39b51
Implement ranges::rotate and ranges::rotate_copy (#1073)
Co-authored-by: Casey Carter <Casey@Carter.net>
2020-07-29 21:11:32 -07:00
Casey Carter 30777d5adf
Fix thinko in ranges::iter_swap (#1072)
...by transposing arguments to `_Iter_exchange_move`.

Fixes #1067
2020-07-29 20:57:47 -07:00
statementreply e9f56a6148
Finish P0811R3 midpoint and lerp (#1048)
* Removes workaround for missing `bit_cast` and mark `lerp` constexpr.

* Changes how `lerp` handles infinite inputs according to
  https://github.com/microsoft/STL/issues/65#issuecomment-563811523 and
  https://github.com/microsoft/STL/issues/65#issuecomment-564102550.

* Adds constexpr tests.

Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-07-29 20:49:20 -07:00
Alex Guteniev 0e7b5d2509
<valarray>: Implement copies for slice_array, gslice_array, mask_array, and indirect_array (#988)
Co-authored-by: S. B. Tam <cpplearner@outlook.com>
Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-07-29 20:30:29 -07:00
Casey Carter 35ce1cf44a
Fix the interaction between _Pass_fn and invoke (#1091)
`_Pass_fn` returns a copy of arguments no larger than `void*`, and a call-forwarding reference-wrapper-alike `_Ref_fn` for larger function objects. This became a problem when Ranges started throwing pointers-to-member at `_Pass_fn` with the expectation that they would eventually be `invoke`d: pointers-to-member can be larger than `void*`, but `_Ref_fn` doesn't speak the `invoke` protocol.

There are two relatively obvious possible fixes:
1. Teach `_Pass_fn` to always return copies of pointers-to-member regardless of size
2. Teach `_Ref_fn` to obey the `invoke` protocol

(1) results in "large" pointers-to-member that can't be enregistered being copied and passed by hidden reference resulting in larger codesize than (2), but with no corresponding performance benefits. We therefore implement (2) by teaching `_Ref_fn` to call-forward through `invoke` when it wraps a pointer-to-member.

Fixes GH-1089.
2020-07-28 15:34:37 -07:00
Casey Carter 868cf267a0
Implement ranges::move_backward (#1053)
* Implement ranges::move_backward

Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Co-authored-by: mnatsuhara <46756417+mnatsuhara@users.noreply.github.com>
2020-07-28 15:31:55 -07:00
Casey Carter 3659f3dc18
Implement Ranges Set Operations (#1044)
Includes the `mergeable` concept and algorithms `ranges::includes`, `ranges::set_union`, `ranges::set_intersection`, `ranges::set_difference`, and `ranges::set_symmetric_difference`.
2020-07-28 15:26:06 -07:00
Michael Schellenberger Costa f49ffafb5d
Uglify the current member of move_iterator (#1080) 2020-07-27 11:42:15 -07:00
Stephan T. Lavavej b2f1556d2a
Update .clang-format for Clang 10 (#1075)
* Remove unnecessary comments in ranges tests.

We taught clang-format how to sort like this automatically.

* Fix x86 compiler error in stljobs.h.

This never compiled for x86 where size_t and SIZE_T are different types.

* Update .clang-format for Clang 10.

AllowShortBlocksOnASingleLine changed from false/true to
Never/Empty/Always. We still want the default of Never, as Empty
appears to misbehave.

DeriveLineEnding was added, defaulting to true. We want to disable line
ending auto-detection.

SortPriority was added. Its documentation is difficult to understand,
but it can be used to group includes together while modifying their
otherwise-lexicographic ordering. Here, I'm using it to group WinSDK
includes together, while still sorting WinIoCtl.h last.

IncludeIsMainSourceRegex was added. This doesn't appear to be relevant
to us.

IndentGotoLabels was added. We've avoided goto.

SpaceInEmptyBlock was added. We prefer the default of no space.

SpacesInConditionalStatement was added. We definitely prefer the
default of no space.

SpaceBeforeSquareBrackets was added. Again, we definitely prefer the
default of no space.

The Standard option was overhauled. Previously, Cpp11 meant "use the
latest supported standard". That was confusing, so it has been
deprecated in favor of Latest.

UseCRLF was added. We currently use CRLF for all files. (Previously,
validate.cpp would detect LF files, but clang-format wouldn't fix
them.)

* In .clang-format, delete empty lines and move comment.

The empty lines were intended to make it easier to see customized
options, but they were actually making it harder to diff the default
config against our config.

Move the StatementMacros comment next to our customized settings,
and rewrap it.

* Reformat filesystem.cpp.
2020-07-27 11:38:12 -07:00
Michael Schellenberger Costa fc3df2f5b1
Modernize ranges::all_of and friends (#1061) 2020-07-27 11:34:50 -07:00
Michael Schellenberger Costa 5ada43e908
Modernize ranges::for_each (#1060) 2020-07-27 11:33:40 -07:00
Michael Schellenberger Costa 98f37c302a
Modernize the ranges::find family (#1058)
Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
2020-07-27 11:28:04 -07:00
Michael Schellenberger Costa 99241dce6d
Implement ranges::sample and ranges::shuffle (#1052)
Co-authored-by: statementreply <statementreply@gmail.com>
2020-07-27 11:25:42 -07:00
Michael Schellenberger Costa 28efc70584
Implement ranges::unique family (#1039)
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Co-authored-by: Casey Carter <Casey@Carter.net>
2020-07-27 11:22:29 -07:00
statementreply 8e8770cb16
<random>: Fix discrete_distribution result out of range (#1025)
Mathematically, `_Par0._Pcdf.back()` should be one. However, when it is
actually slightly smaller than one due to rounding error, there is a
small probability that `_Px > _Par0._Pcdf.back()` and the original code
returns the invalid value of `_Par0._Pcdf.size()`.
2020-07-27 11:17:11 -07:00
pawREP 1555e0b861
Vectorize reverse_copy() (#804)
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-07-27 11:06:41 -07:00
Alex Guteniev c10ae01b4d
Atomic CAS with pad (#23, P0528R3) (#1029)
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Co-authored-by: Casey Carter <cartec69@gmail.com>
2020-07-21 01:00:51 -07:00
Billy O'Neal 6c044964f8
<system_error> Enable [[msvc::noop_dtor]] from Visual Studio 2019 version 16.8. (#1016)
Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-07-21 00:55:06 -07:00
Casey Carter 7930d3512f
<compare>: Fix 0 <=> partial_ordering::unordered (#1049)
* Break <compare> ABI again, and fix #1050.

* Remove obsolete conditional compilation from <compare>.

Co-authored-by: statementreply <statementreply@gmail.com>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-07-20 16:54:04 -07:00
Casey Carter 4f949afa0e
Implement ranges::reverse (#1028)
Co-authored-by: Ahana Mukhopadhyay <t-ahmukh@microsoft.com>
2020-07-20 16:45:04 -07:00
Casey Carter 21acd23ad8
Implement ranges::copy_backward (#1026)
* Implement ranges::copy_backward

Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
2020-07-16 22:10:13 -07:00
Christian Fersch 0965adad9a
Use permissive wide-to-narrow transcoding in filesystem_error (#1010) 2020-07-16 22:06:09 -07:00
Michael Schellenberger Costa 16db9931be
Implement ranges::remove family (#1005) 2020-07-16 22:03:12 -07:00
Michael Schellenberger Costa 002cdc65a9
Implement ranges::transform (#941)
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
2020-07-16 21:54:37 -07:00
Michael Schellenberger Costa f357e2c3cb
Implement ranges::replace, ranges::replace_copy, ranges::replace_copy_if (#983)
Co-authored-by: Casey Carter <Casey@Carter.net>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-07-11 16:59:25 -07:00
Stephan T. Lavavej 294355d4fa
Provide comparison operators for map/set/etc. instead of _Tree (#1022)
Fixes #215.
2020-07-11 15:42:17 -07:00
Stephan T. Lavavej a09bfc7696
Code cleanup: Brace for impact (#1020)
* Change meow<>() to meow<>{}.

* Change meow<>{} to meow{} when C++17 has CTAD.
2020-07-11 15:39:24 -07:00
Casey Carter 6d441a10f4
Implement most ranges partition algorithms (#976)
Includes `ranges::is_partitioned`, `ranges::partition`, `ranges::partition_copy`, and `ranges::partition_point`.
2020-07-11 15:30:17 -07:00
Michael Schellenberger Costa 672bcb29a6
Modernize ranges::count_if (#975) 2020-07-11 15:05:45 -07:00
Michael Schellenberger Costa c99a4f32d7
Modernize ranges::count (#974)
Co-authored-by: Casey Carter <cartec69@gmail.com>
2020-07-11 14:56:07 -07:00
Michael Schellenberger Costa 1f0f88f946
Modernize ranges::move (#970)
Co-authored-by: Casey Carter <Casey@Carter.net>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
2020-07-11 14:52:39 -07:00
Michael Schellenberger Costa 215ec06bf6
Modernize ranges::copy_if (#958)
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-07-11 14:47:22 -07:00
Michael Schellenberger Costa d31b0c7bdb
Remove invalid overload of ranges::copy_n (#957)
Co-authored-by: Casey Carter <cartec69@gmail.com>
2020-07-11 14:38:25 -07:00
Michael Schellenberger Costa d1cae3aeef
Modernize ranges::copy (#956)
Co-authored-by: Casey Carter <Casey@Carter.net>
2020-07-11 14:26:56 -07:00
ahanamuk ee6019de81
Implement ranges::generate and ranges::generate_n (#905)
Co-authored-by: Casey Carter <Casey@Carter.net>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-07-11 14:20:10 -07:00
Casey Carter d531112e1e
Correct naked `if constexpr` in C++14 mode (#1011)
Fixes VSO-1152720.
2020-07-07 14:25:22 -07:00
Casey Carter 896e137c52
Style cleanup of requires\s*\( (#999)
* Style cleanup of `requires\s*\(`

To consistently follow the guidelines established in #982.

Fixes #982.
2020-07-07 14:24:04 -07:00
God-father1 89c3b4910c
Update _MSVC_STL_UPDATE for July 2020 (#989) 2020-07-07 14:21:55 -07:00
Alex Guteniev 7253921718
Use new 64-bit interlocked intrinsics on x86 (#986)
* Use new 64-bit interlocked intrinsics on x86

Resolves #965.

Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
2020-07-07 14:15:51 -07:00
Michael Schellenberger Costa aac7b3fbb1
Implement ranges::replace_if (#984) 2020-07-07 14:11:49 -07:00
Stephan T. Lavavej 06827feb4c
Code cleanups: remove workarounds, use braces (#978)
* Fix #433: Warnings C4472 and C4571 were removed in VS 2019 16.6.
* Fix #693: Remove workarounds now that we require VS 2019 16.7.
* Use braces to construct tags (especially `_Iter_cat_t`), function objects, and empty `shared_ptr`s.
2020-07-07 14:08:27 -07:00
Casey Carter 37f5689197
Cleanup `using _Pred` and `using operator<` comments (#977)
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
2020-07-07 14:05:59 -07:00
Alex Guteniev 5be7d49c24
Revert #653 "<chrono>: Cache QPF() and divide just once" (#972)
This reverts commit ad1a26ad97 which was later modified by #694.

Fixes #971.

Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-07-02 18:52:44 -07:00
Adam Bucior 98a10bf2e2
P1065R2 constexpr INVOKE (#703)
Fixes #51.

Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
Co-authored-by: Casey Carter <Casey@Carter.net>
2020-07-02 18:28:50 -07:00
Casey Carter 585583b54c
Implement ranges heap algorithms (#930)
`ranges::is_heap`, `ranges::is_heap_until`, `ranges::make_heap`, `ranges::push_heap`, `ranges::pop_heap`, and `ranges::sort_heap`.
2020-07-02 07:36:30 -07:00
DailyShana 3d7fa78426
Implement LWG-3070 (#923) 2020-07-02 07:29:34 -07:00
ahanamuk 9b248c7041
Implement ranges::swap_ranges (#918) 2020-07-02 07:27:54 -07:00
ahanamuk 123b2b2bfa
Implement ranges::fill and ranges::fill_n (#904) 2020-07-02 07:24:14 -07:00
Charlie Barto 5e3423a377
MSVC <bit> (#795)
Adds MSVC support to the `<bit>` functions.
2020-07-01 20:27:49 -07:00
Stephan T. Lavavej afcf7b608d
Implement noop_coroutine(). (#961) 2020-07-01 18:29:27 -07:00
Casey Carter 3f6c715563
Cleanup: remove unneeded [[maybe_unused]] annotations (#920)
... from variables that are used only on some `if constexpr` branches.
2020-06-29 22:40:14 -07:00
Casey Carter ac5c8b006a
Implement the "binary search" ranges algorithm family (#917)
Includes `ranges::lower_bound`, `ranges::upper_bound`, `ranges::equal_range`, and `ranges::binary_search`.
2020-06-29 22:40:00 -07:00
Casey Carter c114d51fd1
Implement ranges min/max/minmax algorithms (#916)
* `ranges::min` (direct, `range`, and `initializer_list` overloads)
* `ranges::max` (direct, `range`, and `initializer_list` overloads)
* `ranges::minmax` (direct, `range`, and `initializer_list` overloads)
* `ranges::min_element` (`range` only)
* `ranges::max_element` (`range` only)
* `ranges::minmax_element` (`range` only)
* `ranges::clamp` (direct only)

Implements concept `indirectly_copyable_storable`, and adds test coverage for both that concept and `indirectly_movable_storable`.
2020-06-29 22:39:38 -07:00
Casey Carter 021af3e68e
Implement ranges::search_n (#914) 2020-06-29 22:39:10 -07:00
Alex Guteniev bc077c64f3
Use __iso_volatile_store64 for relaxed atomics on x86, and use __iso_volatile_store64 unconditionally (#694) 2020-06-29 21:36:59 -07:00
Casey Carter 81d88bd8e4
Implement ranges::is_sorted and ranges::is_sorted_until (#915) 2020-06-27 06:48:15 -07:00
Casey Carter 9d95c4e9b7
Implement std::permutable and std::sortable (#925) 2020-06-27 06:47:46 -07:00
statementreply 5b49a88058
LWG-2597 std::log misspecified for complex numbers (#884)
Use `_Abs` and `_Copysign` instead of branching on `x < 0`, correctly treating negative zero as a negative number. This matters when branch cuts of a complex function lies on the real or the imaginary axis, where the results for positive zero and negative zero are different.

For negative real number `x`, `pow(x - 0i, y)` and `pow(x + 0i, y)` are different:
```
pow(x - 0i, y) = exp(y * log(x - 0i)) = exp(y * (log(|x|) - πi))
pow(x + 0i, y) = exp(y * log(x + 0i)) = exp(y * (log(|x|) + πi))
```
Thus `pow(complex, real)` can't simply return `_Pow(real, real)` when the imaginary part of the base is negative zero.

Also modifies `pow(complex, complex)` to be consistent with `pow(real, complex)` when the base is a positive real number.
2020-06-27 06:46:01 -07:00
Stephan T. Lavavej 4deaf6cb27
More code cleanups in stl/src (#912) 2020-06-24 01:31:54 -07:00
Casey Carter 3c139980b6
Implement ranges::search (#896)
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-06-24 00:54:23 -07:00
Stephan T. Lavavej c8144e3a03
Require VS 2019 16.7 Preview 2 or later. (#911) 2020-06-24 00:12:51 -07:00
Berrysoft 5d4f4afbed
Fix std::pow's "sufficient additional overloads" (#903)
Fixes #890.

Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-06-23 23:53:04 -07:00
Casey Carter f1515e04fd
Internal headers have extension .hpp (#902) 2020-06-23 23:45:44 -07:00
Casey Carter 70d23a16a6
Implement ranges::is_permutation (#892)
Co-authored-by: mnatsuhara <46756417+mnatsuhara@users.noreply.github.com>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-06-23 23:35:02 -07:00
Michael Schellenberger Costa 569efaba62
Simplify span's representation (#877)
Fixes #874.

Co-authored-by: Casey Carter <Casey@Carter.net>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-06-23 23:26:27 -07:00
Casey Carter 65df32eb73
Implement ranges::_Ubegin and ranges::_Uend CPOs (#901)
Fixes #898.
2020-06-20 00:21:42 -07:00
Stephan T. Lavavej 5813b85aa2
Code cleanups in stl/src (#900) 2020-06-20 00:10:56 -07:00
Hikmat Farhat 44c22f30ac
Updated _MSVC_STL_UPDATE macro (#897)
Fixes #895.
2020-06-19 23:58:24 -07:00
ahanamuk e507f7de17
<algorithm>: Implemented ranges::move (#888)
Co-authored-by: Casey Carter <Casey@Carter.net>
2020-06-19 23:50:20 -07:00
Jonathan Emmett 0cdf5fbfac
Library support for C++20 coroutines (#894)
* Library support for C++20 coroutines

Implements most of <coroutine>. Usefulness of this header is dependent
on a compatible compiler (e.g. Visual Studio 2019 16.8 Preview 1 or
later) that defines `__cpp_impl_coroutine`. With such a compiler
this header exposes the coroutine library support in the `std` namespace
without the need for an `/await` switch.

This implementation is not yet complete:

- noop coroutines are not yet implemented
- symmetric transfer is not yet implemented

The value of `__cpp_lib_coroutine` is defined to a value less than the
Standard-mandated value to represent the incomplete feature.

Co-authored-by: Daniel Marshall <xandan@gmail.com>
2020-06-17 09:08:37 -07:00
Casey Carter 2b0aa05918
<optional>: Don't zero storage in default constructor (#878)
* <optional>: Don't zero storage in default constructor

Providing a minor runtime and codesize benefit.
2020-06-11 14:10:57 -07:00
Sumit Bhardwaj aae2fd2f0a
Fix not unlocking and relocking in condition_variable_any::wait_for (#685) 2020-06-11 14:02:52 -07:00
Stephan T. Lavavej 40c3f1fe9a
Code cleanup: avoid macro-like identifiers, remove double newlines (#865) 2020-05-29 17:51:28 -07:00
Stephan T. Lavavej 191b184004
_CONSTEXPR20 _Copy_s, simplify char8_t compare. (#861) 2020-05-29 17:41:49 -07:00
Casey Carter 3ad64fc201
<variant>: silence useless warning (#858) 2020-05-29 17:37:02 -07:00
Alex Guteniev c4c482105a
<execution>: comment early return control flow (#849)
Fixes #818.
2020-05-29 17:33:46 -07:00
Michael Schellenberger Costa afaac161be
Modernize and extend _Equal_memcmp_is_safe (#831)
Fixes #819.

Co-authored-by: Casey Carter <Casey@Carter.net>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-05-29 17:21:48 -07:00
Michael Schellenberger Costa 212de15c59
P1032R1 Miscellaneous constexpr (#491) 2020-05-23 00:03:27 -07:00
Casey Carter 588dd39de4
LWG-3446 now has a number (#841) 2020-05-18 17:42:53 -07:00
Casey Carter 0e4c6412df
Allow both ::value_type and ::element_type in indirectly_readable_traits (#834)
Per [readable.traits], `indirectly_readable_traits<T>::value_type` is the same type as `remove_cv_t<T::value_type>` if it denotes an object type, or `remove_cv_t<T::element_type>` if it denotes an object type. If both `T::value_type` and `T::element_type` denote types, `indirectly_readable_traits<T>::value_type` is ill-formed. This was perhaps not the best design, given that there are iterators in the wild (Boost's unordered containers) that define both nested types. `indirectly_readable_traits` should tolerate iterators that define both nested types consistently.

Fixes VSO-1121031.
2020-05-15 09:48:14 -07:00
Stephan T. Lavavej e76f500cb3
Code cleanups (#827) 2020-05-14 15:58:54 -07:00
Alex Guteniev ad1a26ad97
<chrono>: Cache QueryPerformanceFrequency() and divide just once (#653) 2020-05-14 15:49:17 -07:00
Casey Carter 995401051f
Implement ranges::adjacent_find (#822) 2020-05-14 15:44:21 -07:00
Casey Carter 79c602144b
Implement ranges::find_first_of (#821) 2020-05-14 15:39:23 -07:00
Daniil Goncharov 48f79a3112
<utility> P0586R2 Integer Comparison Functions (#621)
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-05-14 15:20:28 -07:00
Casey Carter 46ae5f8234
Fix race in parallel adjacent_find (#816)
Check cancellation status _before_ getting a chunk of work to process, instead of after. If we check after and a result was found in a later block than the one we were assigned, we won't notice a better result in our block.
2020-05-12 14:11:32 -07:00
Casey Carter 21046cc515
Implement ranges::find_end (#815) 2020-05-12 14:10:36 -07:00
Alex Guteniev 7353cd1fbc
atomic_flag_test, lock free type aliases (#684)
Addresses #52 (Partially implements P1135R6).

Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-05-12 14:08:04 -07:00
Alex Guteniev 9a0a17e66c
Improve call_once performance by using Init­Once­Begin­Initialize / InitOnceComplete (#688)
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Co-authored-by: Curtis Bezault <curtbezault@gmail.com>
2020-05-11 16:38:36 -07:00
Jean Philippe 11150ca667
Use _Next_iter(it) and _Prev_iter(it) instead of it + 1 and it - 1 (#803) 2020-05-07 17:09:08 -07:00
Casey Carter 07627b63ea
C++20 move_iterator changes and move_sentinel (#787)
* C++20 move_iterator changes and move_sentinel

Changes primarily come from P0896R4 "<ranges>", but the `operator<=>` from P1614R2 "Adding Spaceship <=> To The Library" is here as well.

I've also speculatively implemented the proposed resolutions of LWG-3293, LWG-3391, and LWG-3435.

I had to [patch a pair of libc++ tests](https://reviews.llvm.org/D79343) that fail with these changes; the LLVM reference is updated here to pull in those tests.

Drive-by:
* s/explicit constexpr/constexpr explicit/g (I somehow managed to sneak two occurrences into `subrange`)

* Skip flaky libc++ test (detached threads)
2020-05-07 16:02:40 -07:00
Jean Philippe bb9e6d48ab
Use *_Prev_iter(it) instead of *(it - 1) (#771)
Fixes #465.
2020-05-06 18:18:25 -07:00
Stephan T. Lavavej 5e3f23d3aa
Fix filesystem's handling of nonexistent network paths emitting ERROR_INVALID_NAME (#800)
* Map ERROR_INVALID_NAME to errc::no_such_file_or_directory.

* Update test to accept ERROR_INVALID_NAME.
2020-05-06 18:11:13 -07:00
Casey Carter 1c918ecfcc
C6294 is suppressed STL-wide; remove local suppressions (#794) 2020-05-06 18:03:54 -07:00
Stephan T. Lavavej 65d98ffaba
Fix complex's Sufficient Additional Overloads (#791)
* Fixes GH-785, which reported that `arg(real)` was implemented as `return 0;`
but `arg(complex)` does actual work for complex numbers with
zero imaginary parts.

* `norm` should upgrade to `double` before squaring. The difference
is observable because `double`'s range is vast.

* `conj` and `proj` should return `complex`.

* `conj(real)` should behave exactly like `conj(complex)`, returning
an imaginary part of negative zero. The difference is technically
observable.

* `proj(real)` should behave exactly like `proj(complex)`, mapping
negative infinity to positive infinity.

* Test that float/double/long double aren't "upgraded".

* Tests pass for Clang, emit warnings for MSVC.
2020-05-05 13:36:07 -07:00
Koki Nishihara 430b569d0a
Update _MSVC_STL_UPDATE in yvals_core.h (#793) 2020-05-05 12:39:46 -07:00
Casey Carter c6c430be08
Implement LWG-3420 (#786) 2020-05-05 12:34:56 -07:00
Stephan T. Lavavej 2f4c5792b2
Fix CUDA warnings/errors, _Noinit shadowing, other cleanups (#772) 2020-05-01 14:53:40 -07:00
Casey Carter f0f0b55d57
Silence clang warning in <variant> (#768)
Clang complains about an "unnecessary" lambda capture despite that the capture is used in a discarded statement (LLVM-45398).
2020-04-30 12:12:55 -07:00
Sumit Bhardwaj d7f855891b
Remove _For_each_tuple_element in scoped_lock (#760)
Fixes #738.
2020-04-30 03:51:20 -07:00
Casey Carter 045f3dd0e1
C++20 reverse_iterator changes (#759)
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-04-30 03:15:16 -07:00
Casey Carter d346a6a4be
__cpp_consteval indicates support for consteval (#765) 2020-04-30 03:06:00 -07:00
Alex Guteniev a5a9e49fc6
Optimize `atomic_thread_fence` (#740)
Fixes #739.
2020-04-30 03:00:25 -07:00
Stephan T. Lavavej 2c441c7e03
Improve build instructions and cleanup code (#764)
Fixes #518.
2020-04-30 02:49:14 -07:00
Curtis J Bezault 84221fbe95
Clang warnings cleanup (#755)
Fix Clang warnings in STL headers (when they aren't being suppressed for "system headers").

Change the test infrastructure to no longer treat STL headers as "system headers", so we'll remain clean with respect to Clang warnings in the future.

Fix Microsoft-internal VSO-609129 "`<cvt/sjis_0208>` appears to have impossible condition" which was also emitting a Clang warning.
2020-04-30 02:37:48 -07:00
Josh Soref 79dd533569
Fix spelling (#743) 2020-04-30 02:27:56 -07:00
Stephan T. Lavavej e4bc00e70c
Remove and update compiler bug workarounds (#742) 2020-04-30 02:23:37 -07:00
Daniil Goncharov 2bc5f9bc71
P0415R1 constexpr For <complex> (Again) (#367)
Fixes #16 and fixes #190.

Co-authored-by: Curtis.Bezault <curtbezault@gmail.com>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-04-30 02:13:55 -07:00
Casey Carter 343e625427
Implement ranges::subrange and ranges::view_interface (#734)
* Implement ranges::subrange and ranges::view_interface

Product changes:
`<utility>`: declare `tuple`'s overloads of `std::get` so they are visible to the definition of `subrange`'s `_Pair_like` concept in `<xutility>`.
`<xutility>`: Implementations of `subrange`, `view_interface`, and `borrowed_subrange_t`.

Test changes:
`std/include/range_algorithm_support.hpp`: Remove `iter_move` overload landmine for non-`indirectly_readable` `test_iterator`s that hampers detection.
`std/tests/P0896R4_ranges_algorithm_machinery`: Enable `borrowed_subrange_t` smoke test.
`std/tests/P0896R4_ranges_range_machinery`: Validate that `subrange` is a `borrowed_range`.
`std/tests/P0896R4_ranges_subrange`: New test to cover `subrange` and `view_interface`.
2020-04-24 18:59:20 -07:00
Stephan T. Lavavej b64eeed4ef
Silence Clang -Wc++20-extensions. (#737) 2020-04-24 18:45:04 -07:00
Michael Schellenberger Costa ca032aebb0
Remove _ITERATOR_DEBUG_ARRAY_OVERLOADS (#735)
Fixes #660.

Also move `_Array_(const_)?iterator` from `<xutility>` to `<array>`, since it's no longer needed by the IDAO.
2020-04-24 18:44:01 -07:00
Charlie Barto 0cbd1b2470
Remove EDG-related workaround for bit_cast (#733)
This was Microsoft-internal VSO-1041044.
2020-04-22 01:53:51 -07:00
Stefan Stipanovic b1c18611b9
<atomic>: Remove _ENABLE_ATOMIC_ALIGNMENT_FIX (#723)
Fixes #717.
2020-04-22 01:42:24 -07:00
Abhishek Bhattacharya b76647085e
Refactored some `for` loops to the normal pattern. (#709)
Fixes #678.
2020-04-22 01:38:41 -07:00
Alex Guteniev 97f9a2ce25
<functional>: std::function doesn't handle over-aligned types (#698)
Fixes #690.
2020-04-22 01:34:49 -07:00
Michael Schellenberger Costa 72c724007c
P1831R1 Deprecating volatile In The Standard Library (#634)
Fixes #558.
2020-04-22 01:30:11 -07:00
Casey Carter 53137aa4c0
Suppress C5219 in the STL (#730)
C1XX now emits C5219 `implicit conversion from '%s' to '%s', possible loss of data` to warn about potentially lossy implicit conversions, e.g., from integer types to floating-point types. These changes avoid emission of the new warning from the internals and tests of the STL.
2020-04-21 09:23:09 -07:00
Stephan T. Lavavej 51446475c1
Fix boyer_moore_searcher with the Rytter correction (#724)
Fixes #713.
2020-04-20 14:37:13 -07:00
Casey Carter ae34ee631f
Require MSVC 19.26 and Clang 10 in the STL (#708)
* `<yvals_core.h>` changes:
  * Clang 10 `_HAS_CONDITIONAL_EXPLICIT` in C++14 mode (Only CUDA now requires the `_HAS_CONDITIONAL_EXPLICIT == 0` code paths)
  * reject Clang < 10
  * reject MSVC < 1926

* Unskip libc++ tests that need Concepts and/or `<=>`

* `std/tests/P0595R2_is_constant_evaluated`: We no longer need  suppress the warning Clang 9 emits when it sees the suppression for the warning Clang 10 emits in this test ;)

* `std/tests/VSO_0157762_feature_test_macros`: Remove Clang 9 support

* `std/tests/concepts_matrix.lst`: This is now simply a copy of `usual_latest_matrix.lst` with the `/BE` lines (EDG configs) commented out. (i.e., we now run the Concepts tests with Clang as well as MSVC.)

* Remove workarounds for LLVM-38491 "clang-cl should accept __declspec(allocator)": Replace uses of `_DECLSPEC_ALLOCATOR` with `__declspec(allocator)`, and suppress Clang's warning when the return type isn't a pointer or reference.

* Remove workarounds for LLVM-43531 "clang-format damages 'alternative representations' for operators": Re-enable clang-format in the test which triggered the bug.

* Remove workarounds for LLVM-38478 "clang -fno-ms-compatibility rejects Windows.h": Add -fno-ms-compatibility to the XXX_winsdk_XXX.lst files. (Yes, we still need these because the Windows SDK breaks `/Za`.)

* Drive-by: unskip libc++ new.version now that we implement destroying delete
2020-04-13 13:09:34 -07:00
Michael Schellenberger Costa bda4230d58
<numeric> Optimize gcd to use builtins (#665)
* [numerics] Optimize gcd to use builtins

* Fix template argument deduction for _countl_zero

* Use the same casts as the other bit operations

* Update stl/inc/numeric

Fix tpyo

* Remove whitespace

Co-Authored-By: Stephan T. Lavavej <stl@nuwen.net>

* _BitScanForward is countr_zero(x), not countl_zero(~x)

Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Co-authored-by: Casey Carter <Casey@Carter.net>
2020-04-10 19:09:41 -07:00
Alex Guteniev 764f7cbd6f
<chrono>: Explain steady_clock::now frequency scaling (#658) 2020-04-10 19:08:31 -07:00
Casey Carter d0d059716e
Update FixNamespaceComments to true in various clang-format files (#681)
Now that LLVM-39247 has been fixed in Clang 10, we can enable this setting again. This PR does so in several Libs clang-format files which had a LLVM-39247 comment.

I've changed the end comments on unnamed namespaces from `// namespace`, which clang-format adds automatically, to `// unnamed namespace` which more clearly indicates that someone didn't simply forget to finish typing the comment.
2020-04-10 16:21:06 -07:00
Casey Carter 2a1a375b88
More Clang 10 support (#657)
* Minor test matrix cleanup:
  * Factor "/EHsc /std:c++latest" out of each config in `usual_latest_matrix.lst` and `usual_latest_winsdk_matrix.lst`
  * Remove unused `native_latest_matrix.lst`

* Avoid LLVM-45213 in `range_algorithm_support.hpp` and `std/tests/P0896R4_ranges_alg_all_of`

* <concepts> remove workaround for LLVM-44689 which is fixed in Clang 10
2020-04-10 15:58:11 -07:00
Adam Bucior 433b8a16b6
Implement P0718R2 atomic<shared_ptr<T>>, atomic<weak_ptr<T>> (#601) 2020-04-09 19:56:00 -07:00
Casey Carter 0055b5bf80
<yvals_core.h>: Fix <bit> feature-test macros (#695)
* Don't define `__cpp_lib_bitops` when `__EDG__`, so IntelliSense is consistent with MSVC
* Don't define `__cpp_lib_int_pow2` when `__cpp_lib_bitops` isn't defined since the facilities that correspond with `__cpp_lib_int_pow2` are only provided when `__cpp_lib_bitops` is defined.
* Update feature-test macro test accordingly

(See discussion starting at https://github.com/microsoft/STL/issues/313#issuecomment-585127653.)
2020-04-09 19:27:35 -07:00
Adam Bucior a099e85ce3
P0674R1 make_shared() For Arrays (#309)
Fixes #33.

Co-authored-by: Gianni Weinand <t-giwein@microsoft.com>
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
2020-04-08 12:23:05 -07:00
joemmett 714f499f4b
Library support for P0722R3 - Efficient sized delete for variable siz… (#692)
Library support for P0722R3 - Efficient sized delete for variable sized classes

Implements the struct type `std::destroying_delete_t`, variable
`std::destroying_delete`, and feature test macro
`__cpp_lib_destroying_delete` in C++20 mode with a compiler that defines
`__cpp_impl_destroying_delete`.
2020-04-08 09:38:43 -07:00
Casey Carter 22391019cb
Changes to support the compiler portion of P1152R4 "deprecating volatile" (#674)
* Updates for MSVC implementation of P1152R4 "deprecating volatile"

* Enable volatile deprecation warnings in STL's std and libcxx test suites

* `<any>`: `any_cast<T>` now returns `remove_cv_t<T>` because it's silly to have a cv-qualified return type (LWG issue submitted)
* `<optional>`: `optional<T>::value_or` now returns `remove_cv_t<T>` because it's silly to have a cv-qualified return type (LWG issue submitted).
* `<type_traits>`: suppress deprecation warnings around `_Implicitly_convert_to` so `_Implicitly_convert_to<volatile meow>(woof)` doesn't warn
* `<variant>`: Suppress deprecation warnings when forming the "imaginary" overload set `FUN` for the `variant(T&&)` constructor.
* Add the new warning C5215 "'%s' a function parameter with volatile qualified type is deprecated in C++20" to libc++'s "suppress deprecation warnings" macro and update llvm submodule reference.
* Skip libc++ test `containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp` after seeing one timeout too many in Contest logs.
* Suppress C5215 in `tr1/include/tfuns.h` which uses volatile function parameters, and in `tr1/functional4` altogether.
* Update skips for two libc++ tests that changed suffixes from `.sh.cpp` to `.pass.cpp`.

* Add a throwaway `addCompileFlags` function to `LibcxxTestFormat` to enable libc++ to continue working after upstream changes to pass configuration to the filesystem tests which we do not run.
2020-04-03 18:20:24 -07:00
Alex Guteniev 260cfafb63
<bitset>: Make bitset::all work like bitset::any (#671)
Fixes #669.
2020-04-02 21:50:14 -07:00
s00kee 43e07f3fad
Updated _MSVC_STL_UPDATE to April 2020 (#676)
Fixes #670.
2020-04-02 17:54:50 -07:00
Charlie Barto 3e8b26950f
Revert "Replace __pragma with _Pragma (#662)" (#675)
This reverts commit 42d5df07d0.

Reverting due to a bug in how /Zc:preprocessor handles _Pragma
see VSO-1091758 for more details

Co-authored-by: Charles <barto.charlie+code@gmail.com>
2020-04-02 14:44:09 -07:00
Miroslav Hrnčíř 42d5df07d0
Replace __pragma with _Pragma (#662)
* Replace __pragma with _Pragma

VS 2019 16.6 Preview 2 now supports Standard _Pragma.

* Fix formatting

* _Pragma takes a string
2020-04-01 18:41:51 -07:00
Andrew Marino dba4ef945c
Disable warning C4648 'standard attribute 'x' ignored' (#672)
In a future release of MSVC, the compiler warns with C4648 on uses of `[[no_unique_address]]`, which the compiler recognizes but does not yet implement. Since `<algorithm>` intentionally uses the attribute, disable the warning in STL headers. This mirrors changes in internal MSVC-PR-239026.
2020-04-01 16:18:00 -07:00
Damien 6d5372b027
lerp() noexcept is now required, so we should remove comments (#640) 2020-04-01 11:41:43 -07:00
Alex Guteniev 8e8453c677
<chrono>: Cache QueryPerformanceFrequency() (#646) 2020-03-31 17:35:28 -07:00
Gianni Georg Weinand 90bc6215e4
constexpr for std::array Comparisons (#599)
* Add constexpr to array comparison functions + change feature test macro.

* Fixed clang-format on array and moved comment in yvals_core.h

* Corrected feature test macro constant

* Removed libcxx test skip

* Added constexpr testing for array comparison operators

* clang-formatted the test file

* Added CXX20 feature test macro

* Fixed 0 size array initialization in test file.

* Test variables made global and const, removed to_array, fix typo

* clang-format test file

* Fixed typo, duplicate line and alignment in the constexpr operator test.

* clang-format array

* Changed const global variables to constexpr in test file.

* Removed double parenthesis in test file.

Co-Authored-By: Stephan T. Lavavej <stl@nuwen.net>

* Update tests/std/tests/P1023R0_constexpr_for_array_comparisons/test.cpp

Co-Authored-By: Stephan T. Lavavej <stl@nuwen.net>

* STL's suggestion to avoid disabling clang-format and shorten test.

* clang-format 10 array

* Removed test skip from expected_results.txt to match skipped_tests.txt

Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
2020-03-31 14:33:55 -07:00
Billy O'Neal ff83542af4
Update to Clang 10 and Visual Studio 2019 version 16.6p2 (#645)
* Update to Clang 10 and Visual Studio 2019 version 16.6p2

* re-clang-formats the tree to comply with new clang 10 clang-format
* updates our agents to F series VMs which are faster and cheaper for our build workloads
* defaults scale set to 0 VMs and lets the Azure Pipelines service control all resizing
* fix tests to pass with the new compilers

Co-authored by Casey Carter and Curtis Bezault
2020-03-28 18:53:15 -07:00
Casey Carter 2849d9c39f
<concepts>: Implement is-default-initializable via placement new (#635)
`new T` is correctly ill-formed when `T` cannot be default-initialized (except on MSVC thanks to VSO-1084668).

Fixes #334.
2020-03-26 07:10:31 -07:00
Joyce Er 02043f812c
Remove comment following acceptance of LWG-3150 (#638)
Fixes #528.
2020-03-25 23:45:27 -07:00
WojciechMigda 603971feb8
Bump _MSVC_STL_UPDATE for March 2020 (#637)
Fixes #579.
2020-03-25 23:26:36 -07:00
Sven Haak 7a4d70ae96
<xutility>: strengthen noexcept for array iterators (#627)
Fixes #427.
2020-03-25 23:21:50 -07:00
Krystyna Lopez 6d88a8883e
Fix #239: Improve _Invoke_traits throughput (#408) 2020-03-25 23:14:14 -07:00
Casey Carter 76d94b0c35
<filesystem>: Fix damage caused by redefinition of _Iter_value_t to iter_value_t in concepts mode (#631)
`iter_value_t` doesn't detour through `iterator_traits`, so it can be valid for non-iterator types. This breaks `_Is_Source2`, however, which expects `_Iter_value_t` to filter out non-iterator types.

Drive-by: rename `_Is_Source2` to `_Is_Source_impl` to be consistent with how we name trait helpers elsewhere.

Fixes DevCom-953628.
2020-03-24 13:16:22 -07:00
Casey Carter 02a6ea8b62
Allow Clang10 in the STL (#622)
* Allow Clang10 in the STL

This PR includes changes necessary to allow (but not require) clang 10 in the STL. It also includes test changes to allow the tests to pass given new clang warnings for deprecated behaviors, and an update to the LLVM reference to get similar changes that have been applied upstream to libc++ tests.

Details:
* In `<compare>`, remove workarounds for LLVM-41991 in Clang 10 RC1 fixed in RC2.
* In `<concepts>`, remove `_SILENCE_CLANG_CONCEPTS_MESSAGE`.
* In `<queue>` and `<stack>`, befriend only corresponding specializations of operator templates.
* In `<system_error>`, fix the `__cpp_constexpr_dynamic_alloc` implementation of `_Immortalize_memcpy_image` (which we apparently didn't review at all).
* In `<experimental/filesystem>`, apply a fix equivalent to the resolution of LWG-3244.
* Update `P0220R1_optional` from upstream.
* In `P0595R2_is_constant_evaluated`, silence Clang's warning for using `is_constant_evaluated` in a manifestly constant-evaluated context.
* In `P0896R4_ranges_iterator_machinery`, fix bogus test cases that were expecting VSO-1008447, silence "unused variable" warnings, and avoid taking advantage of too-lenient MSVC comparison rewrite behavior.
* In `P0896R4_ranges_range_machinery`, silence "unused variable" warning.
* In `P0898R3_concepts`, Remove workaround for LLVM-44627 in Clang 10 RC1 fixed in RC2.
* In `VSO_0000000_type_traits` and `tr1/type_traits5`, silence volatile function parameter deprecation warnings.
* In `tr1/condition_variable`, `tr1/regex1`, and `tr1/regex3`, remove unnecessary copy assignment operators that were prompting Clang warnings about the implicitly definition of a copy constructor for such a class being deprecated.
* In `tr1/csetjmp`, silence volatile increment deprecation warnings.

Skip new libc++ tests:
* Various `span` tests that expect `const_iterator` (libc++ doesn't yet implement LWG-3320)
* tests for the implementation of P1135R6 "The C++ Synchronization Library" which we do not yet implement
2020-03-19 16:42:55 -07:00
Casey Carter 300e85650c
Remove STL workarounds for VSO-1006185 (#417)
* Remove STL workarounds for VSO-1006185

...which has been fixed for 16.6p1.

Fixes #416.
2020-03-17 22:23:37 -07:00
Billy O'Neal bf944d2e28
<filesystem> Treat ERROR_BAD_NETPATH as file not found. (#616)
Resolves GH-615 / DevCom-950424.

* Extract _Is_file_not_found to <xfilesystem_abi.h> as __std_is_file_not_found because we also need that in filesystem.cpp.
* Add ERROR_BAD_NETPATH to __std_is_file_not_found.
* Map ERROR_BAD_NETPATH to errc::no_such_file_or_directory.
* Change filesystem tests that look for file not exists behavior to also test bad network paths.
2020-03-17 18:29:50 -07:00
Stephan T. Lavavej 4cce286cf4
Work around compiler bug in atomic. (#614) 2020-03-17 12:46:45 -07:00
pi1024e 32deb989fa
Simplify _FDscale in xfdscale.cpp (#609)
`psx` is `0`, so don't even bother checking.
2020-03-16 15:14:24 -07:00
Casey Carter 2ff4d3447b
P1871R1 disable_sized_sentinel_for (#607)
Rename the variable template `disable_sized_sentinel` to `disable_sized_sentinel_for` for consistency with the name of the associated concept `sized_sentinel_for`.

Addresses #39.
2020-03-16 13:10:19 -07:00
Casey Carter 285187b7b2
P0896R4 changes to insert iterators (#589)
When `defined(__cpp_lib_concepts)`, `(back_|front_|)insert_iterator` are default constructible, and have `ptrdiff_t` as difference type.

Skip libc++ tests broken by this change.
2020-03-09 17:45:17 -07:00
Michael Schellenberger Costa d8b5008ea3
P2116R0 Removing tuple-Like Protocol Support From Fixed-Extent span (#587)
Fixes #556.
2020-03-08 14:16:29 -07:00
Adam Bucior 26b06299b0
<xutility> lexicographical_compare_three_way (#515)
Works towards #64.
2020-03-08 14:07:08 -07:00
Michael Schellenberger Costa b3976d3921
LWG-3255 span's array constructor is too strict (#506)
Fixes #541.
2020-03-08 13:57:03 -07:00
Michael Schellenberger Costa 2af0749fc1
P1976R2 Explicit Constructors For Fixed-Extent span From Dynamic-Extent Ranges (#500)
Fixes #557.
2020-03-08 13:41:14 -07:00
Billy O'Neal 0d75fc5ab6
<functional> Avoid layers of forwards in invoke (#585)
This change removes the last "nonessential" stack frame that would be encountered for threads, and makes the debugging experience for several standard components, like `std::function`, nicer by not needing so many step into / step out of sequences.

![image](https://user-images.githubusercontent.com/1544943/75860992-92b2b000-5db1-11ea-90f1-d7ec3adde21b.png)

1. CRT's thread entry point
2. std::thread's entry point that staples the parameters on
3. invoke
4. already user code yay!

Hopefully this makes debug codegen better too, particularly now that ranges hammers invoke even harder than we used to.

I didn't change any of the metaprogramming for deciding which strategy to use -- I like that we don't use SFINAE to make that decision, and don't really consider myself competent enough a metaprogrammer to confidently make changes there. I just make `_Invoker_xyz` also supply a strategy value that is fed into `if constexpr`. @CaseyCarter suggested some larger changes which might have sped up metaprogramming I tried, but ran into issues because one can't deduce the calling convention of pointers-to-member-function.

I've also made a one time exception to our usual policy of using `std::forward` rather than `static_cast`, with the rationale that `invoke` is hammered *everywhere*, and also by traits, and we want the debugging experience of that to be as nice as possible.

(Also drive-by removed unnecessary compilation of iostreams from the `Dev10_729003_bind_reference_wrapper` I noticed debugging a test case failure)

Co-authored-by: Casey Carter <cartec69@gmail.com>
2020-03-05 15:36:26 -08:00
Charlie Barto 8a6c278743
add bit_cast and tests (#583)
* add bit_cast and tests
Mirror MSVC-PR-228495
2020-03-05 13:57:04 -08:00
Casey Carter b8917400a9
enable_view<T> now defaults to derived_from<T, view_base> (#588)
Implements LWG-3326 "`enable_view` has false positives".

Fixes #543.
2020-03-05 06:14:28 -08:00
Casey Carter 930b843f31
Several range algorithms (#565)
* Several range algorithms

In `<algorithm>`, implement:
* the generic algorithm result types from P2106R0 (lines 75-227)
* `ranges::for_each` and its result alias `for_each_result` (lines 289-322)
* `ranges::for_each_n` and its result alias `for_each_result_n` (lines 324-351) from P1243R4
* `ranges::find` (lines 353-384)
* `ranges::find_if` (lines 396-426)
* `ranges::find_if_not` (lines 454-484)
* `ranges::count` (lines 526-568)
* `ranges::count_if` (lines 587-617)
* `ranges::mismatch` and its result alias `mismatch_result` (lines 798-891)
* `ranges::equal` (lines 893-980)
* `ranges::all_of` (lines 1006-1033)
* `ranges::any_of` (lines 1060-1087)
* `ranges::none_of` (lines 1114-1141)
* `ranges::copy` and its result alias `copy_result` (lines 1143-1175)
* `ranges::copy_n` and its result alias `copy_n_result` (lines 1177-1207)
* `ranges::copy_if` and its result alias `copy_if_result` (lines 1262-1302)

In `<concepts>`:
* implement LWG-3194 which includes the resolution of LWG-3151 (lines 51-53)
* LWG-3175 has been merged, remove conditional implementation (line 183)
* replace `boolean` concept with _`boolean-testable`_ concept from P1964R2 (lines 198-237, 283)
* move `movable` (pun intended) into synopsis order (lines 254-256)
* Modify concept `copyable` per P2102R0 (lines 260-261)
* Implement concept `equivalence_relation` from P1716R3 (lines 290-293)

In `<xutility>`:
* promote `identity` from `<functional>` for visibility in `<algorithm>` (lines 160-168)
* promote `common_range` from `<ranges>` for visibility in `<algorithm>` (lines 3091-3095)
* remove LWG-3247 and LWG-3299 annotations (lines 622, 626, and 963)
* prefix `indirectly_` to the names of `readable_traits`, `readable`, and `writable` (a great many lines); and modify `iter_value_t` (lines 366-367), `iter_reference_t` (lines ), `iter_difference_t`, `iter_rvalue_reference_t`, `indirectly_readable` (lines 688-701) and `indirectly_swappable` per P1878R1
* define alias template `_Make_unsigned_like_t` to implement P1522R1's _`make-unsigned-like-t`_ (it does nothing interesting yet, since we provide no integer-class types) (lines 727-729)
* implement the "Indirect callable" concepts `indirectly_unary_invocable`, `indirectly_regular_unary_invocable`, `indirect_unary_predicate`, `indirect_binary_predicate`, `indirect_equivalence_relation`, `indirect_strict_weak_order`, and helpers `indirect_result_t` and `projected` (lines 852-926)
* implement `indirectly_copyable` and `indirectly_copyable_storable` concepts (lines 939-952)
* implement `indirectly_swappable`, `indirectly_comparable`, `permutable`, `mergeable`, and `sortable` concepts (lines 1032-1061)
* rename `safe_range` and `enable_safe_range` to `borrowed_range` and `enable_borrowed_range` per LWG-3379 (lines 2168-2173 and 2327-2330)
* remove "Implements D2091R0" comments (various lines in 2175-2710)
* add `ranges::data` to the list of access CPOs that hard error for arrays of incomplete element types (lines 2204-2205 and 2277-2278)
* `ranges::empty` rejects arrays of unbound bound per P2091R0 (lines 2664-2692)
* implement concept `_Not_same_as` (the exposition-only _`not-same-as`_ from the working draft) (lines 3087-3089)
* implement `ranges::dangling` (lines 3097-3102)
* implement `ranges::borrowed_iterator_t` (lines 3104-3106)

In `<yvals_core.h>`:
* Indicate implementation of:
  * P1207R4 Movability of Single-Pass Iterators
  * P1248R1 Fixing Relations
  * P1474R1 Helpful Pointers For contiguous_iterator
  * P1716R3 Range Comparison Algorithms Are Over-Constrained
  * P1878R1 Constraining Readable Types
  * P1964R2 Replacing `boolean` with _`boolean-testable`_
  * P2091R0 Fixing Issues With Range Access CPOs
  * P2102R0 Make "implicit expression variations" More Explicit
* and partial implementation of:
  * P1243R4 Rangify New Algorithms
* remove conditional definition of `_HAS_STD_BOOLEAN` (we never has `std::boolean` now)

`tests/std/include/instantiate_algorithms.hpp`:
* define non-movable type `Immobile`, and use it to ensure that standard algorithms neither copy nor move random number generators nor uniform random bit generators

Add header `tests/std/include/range_algorithm_support.hpp` with support machinery for the ranges algorithm tests. It notably defines:
* `is_permissive` for determining whether we are compiling in MSVC's permissive mode (lines 18-37)
* A class template `borrowed<bool>` whose specializations always model `range` and model `borrowed_range` iff the template parameter is `true` (lines 39-46)
* Function objects `get_first` and `get_second` which project the pertinent member from `pair` arguments (lines 48-54)
* A class template `move_only_range<T>` which adapts a `contiguous_range` of `T` into a move-only `view` with move-only `input_iterator`s (lines 56-150)
* A "phony" iterator class template `test_iterator` with tunable category, value type, and difference capability for instantiation tests (lines 152-363)
* A similar "phony" class template `test_range` with tunable category, size, and commonality (i.e., is the sentinel type the same as the iterator type) (lines 365-423)
* "phony" predicate and projection types for instantiation tests (lines 425-442)
* combinatoric instantiation machinery for instantiation tests that instantiate with all interesting kinds of output iterators or input ranges (lines 444-529)

A new compile-only test `tests/std/tests/P0896R4_ranges_algorithm_machinery` which covers:
* `indirectly_unary_invocable`/`indirectly_regular_unary_invocable`
* `indirect_unary_predicate`/`indirect_binary_predicate`/`indirect_result_t`
* `projected`
* `indirectly_copyable`/`indirectly_swappable`/`indirectly_comparable`
* `dangling`/`borrowed_iterator_t`
* the result types `in_found_result`/`in_fun_result`/`in_in_result`/`in_out_result`/`in_in_out_result`/`in_out_out_result`/`min_max_result`

Very simple smoke and instantiation tests for the 15 new algorithms in:
* `tests/std/tests/P0896R4_ranges_alg_all_of`
* `tests/std/tests/P0896R4_ranges_alg_any_of`
* `tests/std/tests/P0896R4_ranges_alg_copy`
* `tests/std/tests/P0896R4_ranges_alg_copy_if`
* `tests/std/tests/P0896R4_ranges_alg_copy_n`
* `tests/std/tests/P0896R4_ranges_alg_count`
* `tests/std/tests/P0896R4_ranges_alg_count_if`
* `tests/std/tests/P0896R4_ranges_alg_equal`
* `tests/std/tests/P0896R4_ranges_alg_find`
* `tests/std/tests/P0896R4_ranges_alg_find_if`
* `tests/std/tests/P0896R4_ranges_alg_find_if_not`
* `tests/std/tests/P0896R4_ranges_alg_for_each`
* `tests/std/tests/P0896R4_ranges_alg_for_each_n`
* `tests/std/tests/P0896R4_ranges_alg_mismatch`
* `tests/std/tests/P0896R4_ranges_alg_none_of`

Resolves:
* #537 `<concepts>`: LWG-3175 has been accepted, so we should remove commented-out code
* #540 LWG-3194 `ConvertibleTo` prose does not match code
* #546 LWG-3379 `safe` in several library names is misleading
* #559 P1964R2 "Replacing `boolean` with _`boolean-testable`_"
* #561 P2102R0 "Making 'Implicit Expression Variations' More Explicit"
* #563 P2091R0 "Fixing Issues With Range Access CPOs"
2020-03-04 22:19:53 -08:00
Casey Carter 369008308c
Implement range_size_t (#514)
per the resolution of LWG-3335.
2020-03-04 22:18:55 -08:00
Stephan T. Lavavej fee81ee626
Replace `_STATIC_UNLESS_PURE` with `static`. (#584)
This was a workaround for a compiler bug (in constexpr initialization)
that has been fixed.
2020-03-03 16:24:56 -08:00
Michael Schellenberger Costa 1cd4e071ff
LWG-3330 Include `<compare>` from most library headers (#513)
Fixes #545.
2020-03-03 13:54:46 -08:00
Michael Scott Mueller 922eec2a12
<filesystem>::space fails with no read access to root (#552)
* <filesystem>::space fails with no read access to root

Avoid the unnecessary call to GetVolumePathNameW because read access for this call is required on the root of the mounted volume. This call used to be required for GetDiskFreeSpace, but should not be used for GetDiskFreeSpaceExW, where the full path should be used. The appropriate read permissions on the given path will be taken into consideration.

Co-authored-by: Billy O'Neal <billy.oneal@gmail.com>
2020-03-03 09:37:04 -08:00
Jean Philippe e967cdc800
<filesystem>: Fix directory_iterator returning "dot" and "dotdot" entries (#562) 2020-03-02 17:27:47 -08:00
Jean Philippe dd8152c8b4
Update byte detection by using __cpp_lib_byte (#577)
Fixes #564.
2020-03-02 15:47:26 -08:00
Xiang Fan b85797476f
Apply a new attribute '[[msvc::known_semantics]]' (#580)
Apply a new attribute '[[msvc::known_semantics]]' to communicate to the compiler that certain type trait specializations have the standard-mandated semantics
2020-03-02 15:30:16 -08:00
mocabe 0e46d7ab99
Fix missing SFINAE in operator/ and operator% for std::chrono::duration (#573) 2020-03-02 12:23:47 -08:00
Svido bb373d11a2
<xutility>: remove LWG issue comment (#568)
Fixes #531.
2020-02-29 14:39:54 -08:00
Svido 51b212a884
LWG-3390 `make_move_iterator()` cannot be used to construct a `move_iterator` for a move-only iterator (#567)
Fixes #547.
2020-02-29 14:37:24 -08:00
Daniel Marshall 627eced6ec
P1115R3 erase()/erase_if() Return size_type (#566)
Fixes #555.
2020-02-29 14:35:24 -08:00
Jean Philippe 5249900144
Avoid declaring multiple variables on a single line (#550)
Fixes #522.
2020-02-29 14:30:33 -08:00
Michael Schellenberger Costa 3e5230dab5
LWG-3320 removes span::const_iterator (#548)
Fixes #542.
2020-02-29 14:27:21 -08:00
Michael Schellenberger Costa 9057993c82
LWG-3329 `totally_ordered_with` both directly and indirectly requires `common_reference_with` (#512)
Fixes #544.
2020-02-29 14:24:36 -08:00
Jean Philippe 577827a79a
Consistently use empty braces to construct tags (#497)
Fixes #468.
2020-02-29 14:21:41 -08:00
Adam Bucior a092e67713
<memory> construct_at() (#501) 2020-02-28 19:19:37 -08:00
Billy O'Neal d4ee5c3fb4
Massively improve the performance of <system_error> and remove constexpr workarounds. (#529)
* Removes VSO-406237 "C1XX does not do constant initialization where the standard requires" workarounds.
* Introduce `_Immortalize_memcpy_image` which avoids the need for synchronization when constructing the error categories. See the big comment block for explanation of how we got here. For compilers which let us declare instances with the empty virtual destructor as constexpr variables (currently only clang in C++20 mode), we can avoid the workaround.
* Turn on `/Zc:threadSafeInit-` and warning 4640 in most tests to ensure we aren't emitting thread-local initializers in `<system_error>`.
* Move `_Immortalizer` and friends to the one remaining caller in the `exception_ptr` implementation.
* Remove `_Generic_error_category` from the base class hierarchies of error categories to workaround DevCom-928781.
2020-02-27 19:03:58 -08:00
Michael Schellenberger Costa b899222aff
Adopt LWG-3264 unconditionally (#511)
Fixes #536.
2020-02-25 19:19:45 -08:00
Charlie Barto e03429600e
P1956R1 <bit> has_single_bit(), bit_ceil(), bit_floor(), bit_width() (#524)
* apply P1956R1

Mirror of MSVC-PR-231381

* rename test folder and update yvals_core naming

* repair test.lst

* fix nitpicks
2020-02-24 19:00:15 -08:00
Billy O'Neal 482f1d8088
Reduce the amount of content included by <array> (#482)
* Reduce the amount of content included by <array>.

Resolves GH-462.

* Demote `back_inserter` and `iterator` to `<iterator>`.
* Demote `_Yarn` to `<xlocinfo>`.
* Demote `_Tidy_guard`, `_Tidy_deallocate_guard`, and `_Nothrow_compare` to `<xmemory>`.
* Promote `_Swap_ranges_unchecked` to `<xutility>`.
* Change `<array>` to include only `<xutility>`.

* Un-demote iterator.

* Workaround many RWC projects that expected std::min and std::max to come from <array>.

* Remove the `_STL_ASSERT` from `std::min` and `std::max`. We normally guard every `op<` with debug checks, but in this case we aren't using it to enforce something like a container invariant; the number of bad op<s we catch with it are likely microscopic.
* Delete `_Min_value` and `_Max_value` from `<utility>`.
* Move `min` and `max` to `<utility>` (in the exact position as the old `_Min_value` and `_Max_value`)
* Change all existing callers of `_Min_value` and `_Max_value` to call `(_STD min)` and `(_STD max)`, respectively.

* Homogenize vector algorithm guards.
2020-02-21 05:55:22 -08:00
Adam Bucior f01ecbbe8e
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.

in `<compare>`, and:

* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
  easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
  `ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
  requirements for the single-type comparison concepts `equality_comparable`,
  `totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
  in `<compare>` to requires only `n + c` template instantiations instead of `cn`
  template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
  `std::partial_ordering` in `<compare>` since (a) it's true if and only if the
  stored value has a particular value, and (b) Clang expects all of the
  comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
  corresponding `operator()` to agree with synopsis order.

Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.

The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-18 17:38:40 -08:00
Jean Philippe ed3cbf3641
Changed macro constants to constexpr variables (#487)
Fixes #270.
2020-02-07 16:02:23 -08:00
Charles Milette a8efb53f4e
Reduce memory consumption of system_category().message() (#457)
This avoids the allocation in _Winerror_message, and introduces a new version of it which uses FORMAT_MESSAGE_ALLOCATE_BUFFER to completely avoid overallocating memory

Fixes #434

Co-authored-by: Billy O'Neal <billy.oneal@gmail.com>
Co-authored-by: Casey Carter <cartec69@gmail.com>
2020-02-07 00:25:31 -08:00
Jean Philippe 1b59f0d1e7
Update _MSVC_STL_UPDATE value to February 2020 (#486)
Fixes #477.
2020-02-06 11:45:20 -08:00
statementreply 06dc0eb841
Fix formula in complex asinh, acosh and acos. (#401) 2020-02-05 22:55:14 -08:00
Svido 5a8afb99ef
syserror.cpp: Use range-for #479 (#481) 2020-02-05 19:27:43 -08:00
Michael Schellenberger Costa b3504262fe
P0619R4 Removing C++17-Deprecated Features (#380)
Fixes #28 and fixes #478.
2020-02-03 02:55:53 -08:00
Michael Schellenberger Costa ed70349f27
P1423R3 char8_t compatibility remedies (#470)
Deletes stream insertion operators for `ostream` with non-`char` character types, and for `wostream` with `charX_t` character types. The `char8_t` operators are deleted in all language modes, but the others are C++20-only to avoid gratuitous breakage (with escape hatch `_HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20`).

Skips libc++ tests that expect the pre-P1423R3 value of `__cpp_lib_char8_t`.

Resolves #59.
2020-02-01 12:27:53 -08:00
Billy O'Neal 94d39ed515
Avoid double strlen for string operator+ and implement P1165R1 (#467)
Resolves GH-53.
Resolves GH-456.

Co-authored by: @barcharcraz
Co-authored by: @ArtemSarmini 

This change adds a bespoke constructor to `basic_string` to handle string concat use cases, removing any EH states we previously emitted in our operator+s, avoiding double strlen in our operator+s,

The EH states problem comes from our old pattern:

```
S operator+(a, b) {
    S result;
    result.reserve(a.size() +b.size()); // throws
    result += a; // throws
    result += b; // throws
    return result;
}
```

Here, the compiler does not know that the append operation can't throw, because it doesn't understand `basic_string` and doesn't know the `reserve` has made that always safe. As a result, the compiler emitted EH handing code to call `result`'s destructor after each of the reserve and `operator+=` calls.

Using a bespoke concatenating constructor avoids these problems because there is only one throwing operation (in IDL0 mode). As expected, this results in a small performance win in all concats due to avoiding needing to set up EH stuff, and a large performance win for the `const char*` concats due to the avoided second `strlen`:

Performance:

```
#include <benchmark/benchmark.h>
#include <stdint.h>
#include <string>

constexpr size_t big = 2 << 12;
constexpr size_t multiplier = 64;

static void string_concat_string(benchmark::State &state) {
    std::string x(static_cast<size_t>(state.range(0)), 'a');
    std::string y(static_cast<size_t>(state.range(1)), 'b');
    for (auto _ : state) {
        (void)_;
        benchmark::DoNotOptimize(x + y);
    }
}

BENCHMARK(string_concat_string)->RangeMultiplier(multiplier)->Ranges({{2, big}, {2, big}});

static void string_concat_ntbs(benchmark::State &state) {
    std::string x(static_cast<size_t>(state.range(0)), 'a');
    std::string yBuf(static_cast<size_t>(state.range(1)), 'b');
    const char *const y = yBuf.c_str();
    for (auto _ : state) {
        (void)_;
        benchmark::DoNotOptimize(x + y);
    }
}

BENCHMARK(string_concat_ntbs)->RangeMultiplier(multiplier)->Ranges({{2, big}, {2, big}});

static void string_concat_char(benchmark::State &state) {
    std::string x(static_cast<size_t>(state.range(0)), 'a');
    for (auto _ : state) {
        (void)_;
        benchmark::DoNotOptimize(x + 'b');
    }
}

BENCHMARK(string_concat_char)->Range(2, big);

static void ntbs_concat_string(benchmark::State &state) {
    std::string xBuf(static_cast<size_t>(state.range(0)), 'a');
    const char *const x = xBuf.c_str();
    std::string y(static_cast<size_t>(state.range(1)), 'b');
    for (auto _ : state) {
        (void)_;
        benchmark::DoNotOptimize(x + y);
    }
}

BENCHMARK(ntbs_concat_string)->RangeMultiplier(multiplier)->Ranges({{2, big}, {2, big}});

static void char_concat_string(benchmark::State &state) {
    std::string x(static_cast<size_t>(state.range(0)), 'a');
    for (auto _ : state) {
        (void)_;
        benchmark::DoNotOptimize('b' + x);
    }
}

BENCHMARK(char_concat_string)->Range(2, big);

BENCHMARK_MAIN();

```

Times are in NS on a Ryzen Threadripper 3970X, improvements are `((Old/New)-1)*100`

|                                 | old x64 | new x64 | improvement | old x86 | new x86 | improvement |
| ------------------------------- | ------- | ------- | ----------- | ------- |-------- | ----------- |
| string_concat_string/2/2        | 12.8697 | 5.78125 |     122.61% | 13.9029 | 11.0696 |      25.60% |
| string_concat_string/64/2       |  62.779 | 61.3839 |       2.27% | 66.4394 | 61.6296 |       7.80% |
| string_concat_string/4096/2     | 125.558 | 124.512 |       0.84% | 124.477 | 117.606 |       5.84% |
| string_concat_string/8192/2     | 188.337 | 184.152 |       2.27% | 189.982 | 185.598 |       2.36% |
| string_concat_string/2/64       | 64.5229 | 64.1741 |       0.54% | 67.1338 | 61.4962 |       9.17% |
| string_concat_string/64/64      | 65.5692 | 59.9888 |       9.30% | 66.7742 | 60.4781 |      10.41% |
| string_concat_string/4096/64    | 122.768 | 122.768 |       0.00% | 126.774 | 116.327 |       8.98% |
| string_concat_string/8192/64    |  190.43 | 181.362 |       5.00% | 188.516 | 186.234 |       1.23% |
| string_concat_string/2/4096     | 125.558 | 119.978 |       4.65% | 120.444 | 111.524 |       8.00% |
| string_concat_string/64/4096    | 125.558 | 119.978 |       4.65% | 122.911 | 117.136 |       4.93% |
| string_concat_string/4096/4096  | 188.337 | 184.152 |       2.27% | 193.337 | 182.357 |       6.02% |
| string_concat_string/8192/4096  | 273.438 | 266.811 |       2.48% | 267.656 | 255.508 |       4.75% |
| string_concat_string/2/8192     | 205.078 | 194.964 |       5.19% | 175.025 | 170.181 |       2.85% |
| string_concat_string/64/8192    | 205.078 | 188.337 |       8.89% | 191.676 |  183.06 |       4.71% |
| string_concat_string/4096/8192  | 266.811 | 256.696 |       3.94% | 267.455 | 255.221 |       4.79% |
| string_concat_string/8192/8192  |  414.69 | 435.965 |      -4.88% | 412.784 |  403.01 |       2.43% |
| string_concat_ntbs/2/2          | 12.8348 |  5.9375 |     116.17% |   14.74 |  11.132 |      32.41% |
| string_concat_ntbs/64/2         | 71.1496 |  59.375 |      19.83% | 70.6934 | 60.9371 |      16.01% |
| string_concat_ntbs/4096/2       | 128.697 | 114.397 |      12.50% | 126.626 | 121.887 |       3.89% |
| string_concat_ntbs/8192/2       | 194.964 | 176.479 |      10.47% | 196.641 |  186.88 |       5.22% |
| string_concat_ntbs/2/64         | 100.446 |  74.986 |      33.95% | 109.082 | 83.3939 |      30.80% |
| string_concat_ntbs/64/64        | 106.027 | 78.4738 |      35.11% | 109.589 | 84.3635 |      29.90% |
| string_concat_ntbs/4096/64      | 164.969 | 138.114 |      19.44% | 165.417 | 142.116 |      16.40% |
| string_concat_ntbs/8192/64      | 224.958 | 200.195 |      12.37% | 228.769 | 200.347 |      14.19% |
| string_concat_ntbs/2/4096       | 2040.32 | 1074.22 |      89.94% | 2877.33 | 1362.74 |     111.14% |
| string_concat_ntbs/64/4096      | 1994.98 | 1074.22 |      85.71% | 2841.93 | 1481.62 |      91.81% |
| string_concat_ntbs/4096/4096    | 2050.78 | 1147.46 |      78.72% | 2907.78 | 1550.82 |      87.50% |
| string_concat_ntbs/8192/4096    | 2148.44 | 1227.68 |      75.00% | 2966.92 | 1583.78 |      87.33% |
| string_concat_ntbs/2/8192       | 3934.14 | 2099.61 |      87.37% | 5563.32 | 2736.56 |     103.30% |
| string_concat_ntbs/64/8192      | 3989.95 | 1994.98 |     100.00% | 5456.84 | 2823.53 |      93.26% |
| string_concat_ntbs/4096/8192    | 4049.24 | 2197.27 |      84.29% | 5674.02 | 2957.04 |      91.88% |
| string_concat_ntbs/8192/8192    | 4237.58 | 2249.58 |      88.37% | 5755.07 | 3095.65 |      85.91% |
| string_concat_char/2            | 12.8348 | 3.44936 |     272.09% | 11.1104 | 10.6976 |       3.86% |
| string_concat_char/8            | 8.99833 | 3.45285 |     160.61% | 11.1964 | 10.6928 |       4.71% |
| string_concat_char/64           | 65.5692 | 60.9375 |       7.60% | 65.7585 | 60.0182 |       9.56% |
| string_concat_char/512          | 72.5446 | 69.7545 |       4.00% |  83.952 | 79.5254 |       5.57% |
| string_concat_char/4096         | 125.558 | 119.978 |       4.65% | 123.475 | 117.103 |       5.44% |
| string_concat_char/8192         |  190.43 | 187.988 |       1.30% | 189.181 | 185.174 |       2.16% |
| ntbs_concat_string/2/2          | 13.4975 | 6.13839 |     119.89% | 14.8623 |   11.09 |      34.02% |
| ntbs_concat_string/64/2         |  104.98 | 79.5201 |      32.02% | 112.207 | 83.7111 |      34.04% |
| ntbs_concat_string/4096/2       | 2085.66 | 1098.63 |      89.84% | 2815.19 | 1456.08 |      93.34% |
| ntbs_concat_string/8192/2       | 3899.27 | 2099.61 |      85.71% | 5544.52 | 2765.16 |     100.51% |
| ntbs_concat_string/2/64         | 71.4983 |  62.779 |      13.89% | 72.6602 | 63.1953 |      14.98% |
| ntbs_concat_string/64/64        |  104.98 | 80.2176 |      30.87% | 111.073 | 81.8413 |      35.72% |
| ntbs_concat_string/4096/64      | 2085.66 | 1074.22 |      94.16% | 2789.73 |  1318.7 |     111.55% |
| ntbs_concat_string/8192/64      | 3989.95 | 2085.66 |      91.30% | 5486.85 | 2693.83 |     103.68% |
| ntbs_concat_string/2/4096       | 136.719 | 128.348 |       6.52% | 122.605 |  114.44 |       7.13% |
| ntbs_concat_string/64/4096      | 167.411 | 142.997 |      17.07% | 168.572 | 138.566 |      21.65% |
| ntbs_concat_string/4096/40      | 2099.61 | 1171.88 |      79.17% | 2923.85 | 1539.02 |      89.98% |
| ntbs_concat_string/8192/40      | 4098.07 | 2246.09 |      82.45% | 5669.34 | 3005.25 |      88.65% |
| ntbs_concat_string/2/8192       |   213.1 | 199.498 |       6.82% | 178.197 | 168.532 |       5.73% |
| ntbs_concat_string/64/8192      | 223.214 | 214.844 |       3.90% | 232.263 | 203.722 |      14.01% |
| ntbs_concat_string/4096/81      | 2148.44 | 1255.58 |      71.11% | 2980.78 | 1612.97 |      84.80% |
| ntbs_concat_string/8192/81      | 4237.58 | 2406.53 |      76.09% | 5775.55 | 3067.94 |      88.25% |
| char_concat_string/2            | 11.1607 | 3.60631 |     209.48% | 11.2101 | 10.7192 |       4.58% |
| char_concat_string/8            | 11.4746 | 3.52958 |     225.10% | 11.4595 |  10.709 |       7.01% |
| char_concat_string/64           | 65.5692 | 66.9643 |      -2.08% | 66.6272 | 60.8601 |       9.48% |
| char_concat_string/512          | 68.0106 | 73.2422 |      -7.14% | 91.1946 | 83.0791 |       9.77% |
| char_concat_string/4096         | 125.558 | 122.768 |       2.27% | 119.432 | 110.031 |       8.54% |
| char_concat_string/8192         | 199.498 | 199.498 |       0.00% | 171.895 | 169.173 |       1.61% |


Code size:
```
#include <string>

std::string strings(const std::string& a, const std::string& b) {
    return a + b;
}
std::string string_ntbs(const std::string& a, const char * b) {
    return a + b;
}
std::string string_char(const std::string& a, char b) {
    return a + b;
}
std::string ntbs_string(const char * a, const std::string& b) {
    return a + b;
}
std::string char_string(char a, const std::string& b) {
    return a + b;
}
```

Sizes are in bytes for the `.obj`, "Times Original" is New/Old, `cl /EHsc /W4 /WX /c /O2 .\code_size.cpp`:

| Bytes | Before | After  | Times Original |
| ----- | ------ | ------ | -------------- |
| x64   | 70,290 | 34,192 |          0.486 |
| x86   | 47,152 | 28,792 |          0.611 |
2020-01-31 16:45:39 -08:00
Casey Carter 10e9288461
<span>: fix cross-type iterator operations (#474)
* <span>: fix cross-type iterator operations

* Implement `<=>` for C++20 relational operator rewrites.
* `span<T>::operator-` now accepts `_Span_iterator<U>` when `remove_cv_t<T>` and `remove_cv_t<U>` are the same type.

Drive-by: implement `n + span_iterator` as a hidden friend, and make it `constexpr`.

Fixes #473.
2020-01-30 08:27:03 -08:00
Casey Carter 70db54d8eb
Bits of cleanup from clang 10 investigation (#475)
I built clang from the `release/10.x` branch to investigate support for the portions of the STL that require concepts. This went swimmingly, until I was blocked by LLVM-44627 "Reversed candidate operator is not found by argument dependent lookup". These are a few fixes and workarounds I discovered in the process of getting some tests to pass before being blocked completely.

Detailed changes:

`<compare>`:
* Workaround LLVM-41991 "c++2a: attributes on defaulted friend functions incorrectly rejected" by using `_NODISCARD` on such functions only for non-clang.

`<concepts>`:
* Fix typo.
* Workaround LLVM-44689 "[concepts] ICE when *this appears in trailing requires-clause" in `std::ranges::swap`.

`<xhash>`:
* Silence clang warning about template parameter shadowing by renaming.

`<xutility>`:
* Clang thinks my `unreachable_sentinel_t` hack is ill-formed.
2020-01-29 20:01:15 -08:00
Stephan T. Lavavej 2bd2bd2db1
Fix #463 by avoiding iterator subscripting. (#464)
This reverts #289 and changes several more algorithms.

Unrelated cleanup: this changes one occurrence of `[[nodiscard]]`
to `_NODISCARD` for consistency.
2020-01-28 14:35:35 -08:00
codicodi fefb1ddb5d Fix x64 build with Boost 1.72 (#428)
* Fix build with Boost 1.72

* Update vcpkg submodule to 3aa5979471

* Update vcpkg as of the morning of 2020-01-27.

Co-authored-by: Billy O'Neal <billy.oneal@gmail.com>
2020-01-27 15:13:53 -08:00
Charlie Barto cb7fc9d4df
Specific specialmath (#447)
* use specific boost.math headers instead of the general one

* I forgot zeta

Corresponding internal pr VSO-224979
2020-01-27 14:44:44 -08:00
Stephan T. Lavavej 00be070e34
Enable more clang-format. (#458)
iso646.h: This suppression is no longer necessary. (Apparently
unrelated to LLVM-43531, fixed after Clang 9.)

xutility: This exceeded 120 columns. clang-format doesn't make it
unreadable, so we should just enable it.
2020-01-25 03:07:01 -08:00
Billy O'Neal 4c91c915d6
Remove dead store to _Count in _Sort_unchecked and other cleanups (#449)
In GH-425 I was forced to add a dead initialization for the _Count variable in _Sort_unchecked in order to comply with constexpr rules. Also, _Sort_unchecked had somewhat complex assignment-in-conditional-expressions going on. This change moves the code around such that the _Count variable is assigned once.

Also:

* Consistently test _ISORT_MAX with <= where possible, and make that an _INLINE_VAR constexpr variable.
* Remove _Count guards of 1 in front of _Insertion_sort_unchecked for consistency. I did performance testing and there was no measurable difference in keeping this check, and it's more code to reason about.
* Avoid needless casts of _ISORT_MAX given that it is now a constexpr constant.
2020-01-24 18:33:16 -08:00
Stephan T. Lavavej c5cde6ecba
is_constant_evaluated() is constantly available. (#454) 2020-01-24 12:10:49 -08:00
Stephan T. Lavavej 544de81c12
Update for VS 2019 16.5 Preview 2 and N4849. (#453) 2020-01-24 12:10:13 -08:00
Stephan T. Lavavej 125df9b6f0
Fix #345: Remove warning C4265 (non-virtual destructor) suppressions. (#452) 2020-01-24 12:09:33 -08:00
Stephan T. Lavavej 616cbea6b3
Fix #224: static_assert is_sorted(). (#451) 2020-01-24 12:08:34 -08:00
Pavol Misik 10a227676c yvals_core.h: Require _MSC_VER 1925 (#430)
Fixes #422.
2020-01-24 12:07:11 -08:00
Pavol Misik 6f39aad760 Update _MSVC_STL_UPDATE value to January 2020 (#429)
Fixes #409.
2020-01-24 12:05:18 -08:00
Michael Schellenberger Costa 0e336ac737 P0935R0 Eradicating Unnecessarily Explicit Default Constructors (#415)
Fixes #41.
2020-01-24 12:01:10 -08:00
Daniil Goncharov b73a0b19a2 <complex> fix pow overload (#383)
Fixes #325.
2020-01-24 11:58:29 -08:00
Adam Bucior a46d897ac0 Finish Fixing Atomic Initialization (P0883R2) (#390)
Co-authored-by: AdamBucior https://github.com/AdamBucior
Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Billy O'Neal <billy.oneal@gmail.com>
2020-01-23 22:50:22 -08:00
Casey Carter f96c61c346
Implement fixes from D2091R0 "Issues with Range Access CPOs" (#432)
* Implement fixes from D2091R0 "Issues with Range Access CPOs"

* Pre-existing: Correctly annotate implementations of outstanding `iter_move` LWG issues. LWG-3247 was not annotated, and LWG-3299 incorrectly annotated as LWG-3270 (the number had to be changed after submission).

* Remove the `initializer_list` poison pills for `ranges::begin`, `ranges::end`, `ranges::rbegin`, and `ranges::rend`. They were necessary only to prevent `initializer_list` from inadvertently opting-in to forwarding-range, and P1870R1 "forwarding-range<T> is too subtle" changed the opt-in.

* Always perform lookups for lvalues in `ranges::size`, `ranges::empty`, and `ranges::data` as is already the case for `ranges::begin`, `ranges::end`, `ranges::rbegin`, and `ranges::rend` post-P1870, which makes the CPOs easier to reason about and reduces template instantiations.

* Replace forwarding-reference poison pills with pairs of lvalue/const lvalue poison pills for `ranges::begin`, `ranges::end`, `ranges::rbegin`, `ranges::rend`, and `ranges::size`; the forwarding-reference versions are insufficiently poisonous and allow calls to plain `meow(auto&)`/`meow(const auto&)` templates.

* Only perform ADL probes in `ranges::begin`, `ranges::end`, `ranges::rbegin`, `ranges::rend`, and `ranges::size` for argument expressions of class or enumeration type.

* `ranges::begin`, `ranges::empty`, `ranges::data` accept (lvalue) arrays of unknown bound; `ranges::end` (and consequently `ranges::rbegin` and `ranges::rend`) rejects. Remove `range` constraint from `iterator_t`, so it works with (non-`range`) arrays of unknown bound. Add `range` constraints to the `range_meow_t` "compound" associated type traits, since they no longer get it from `iterator_t`.

* Hard error (with a pretty message) in `ranges::begin`, `ranges::end`, `ranges::rbegin`, or `ranges::rend` when the argument is an array whose element type is incomplete.
2020-01-23 18:13:06 -08:00
Casey Carter 8dc0385763
Remove workarounds for VSO-895622 (#410)
This bug is triggered when unqualified name lookup for `f` in `f(x)` finds only deleted function (template)s at template definition time, resulting in MSVC refusing to perform argument dependent lookup at template instantiation time. Unsurprisingly, all of the C++20 CPOs required workarounds.
2020-01-23 17:22:35 -08:00
Billy O'Neal 3447e56030 Implement constexpr algorithms. (#425)
* Implement constexpr algorithms.

Resolves GH-6 ( P0202R3 ), resolves GH-38 ( P0879R0 ), and drive-by fixes GH-414.

Everywhere: Add constexpr, _CONSTEXPR20, and _CONSTEXPR20_ICE to things.

skipped_tests.txt: Turn on all tests previously blocked by missing constexpr algorithms (and exchange and swap). Mark those algorithms that cannot be turned on that we have outstanding PRs for with their associated PRs.
yvals_core.h: Turn on feature test macros.
xutility:
* Move the _Ptr_cat family down to copy, and fix associated SHOUTY comments to indicate that this is really an implementation detail of copy, not something the rest of the standard library intends to use directly. Removed and clarified some of the comments as requested by Casey Carter.
* Extract _Copy_n_core which implements copy_n using only the core language (rather than memcpy-as-an-intrinsic). Note that we cannot use __builtin_memcpy or similar to avoid the is_constant_evaluated check here; builtin_memcpy only works in constexpr contexts when the inputs are of type char.
numeric: Refactor as suggested by GH-414.

* Attempt alternate fix of GH-414 suggested by Stephan.

* Stephan product code PR comments:

* _Swap_ranges_unchecked => _CONSTEXPR20
* _Idl_dist_add => _NODISCARD (and remove comments)
* is_permutation => _NODISCARD
* Add yvals_core.h comments.

* Delete unused _Copy_n_core and TRANSITION, DevCom-889321 comment.

* Put the comments in the right place and remove phantom braces.
2020-01-22 17:57:27 -08:00
Billy O'Neal 2989323bdc
Optimize the is_permutation family and _Hash::operator== for multicontainers (#423)
* Optimize the is_permutation family and _Hash::operator== for multicontaniers slightly.

<xutility>
4660: _Find_pr is a helper for is_permutation, so move it down to that area.
4684: The SHOUTY banners were attached to functions which were implmentation details of is_permutation, so I fixed them up to say is_permutation and removed the banners for helper functions.
4711: Use if constexpr to avoid a tag dispatch call for _Trim_matching_suffixes. Optimizers will like this because they generally hate reference-to-pointer, and it also serves to workaround DevCom-883631 when this algorithm is constexprized.
4766: Indicate that we are trimming matching prefixes in this loop body, and break apart comment block that was incorrectly merged by clang-format.
4817: In the dual range forward version of the algorithm, calculate the distances concurrently to avoid wasting lots of time when the distances vary by a lot. For example, is_permutation( a forward range of length 1, a forward range of length 1'000'000 ) used to do the million increments, now it stops at 1 increment.
4862: In the dual range random-access version, avoid recalculating _Last2 when it has already been supplied to us.

<xhash>
1404: Move down construction of _Bucket_hi in _Equal_range to before the first loop body using it.
1918: Added a new function to calculate equality for unordered multicontainers. We loop over the elements in the left container, find corresponding ranges in the right container, trim prefixes, then dispatch to is_permutation's helper _Check_match_counts.
Improvements over the old implementation:
* For standard containers, we no longer need to hash any elements from the left container; we know that we've found the "run" of equivalent elements because we *started* with an element in that container. We also never go "backwards" or multiply enumerate _Left (even for !_Standard), which improves cache use when the container becomes large.
* Just like the dual range is_permutation improvement above, when the equal_ranges of the containers are of wildly varying lengths, this will stop on the shorter of the lengths.
* We avoid the 3-arg is_permutation doing a linear time operation to discover _Last2 that we already had calculated in determining _Right's equal_range.
The function _Multi_equal_check_equal_range tests one equal_range from the left container against the corresponding equal_range from the right container, while _Multi_equal invokes _Multi_equal_check_equal_range for each equal_range.

Performance results:

```
Benchmark	Before (ns)	After (ns)	Percent Better
HashRandomUnequal<unordered_multimap>/1	18.7	11.7	59.83%
HashRandomUnequal<unordered_multimap>/10	137	97	41.24%
HashRandomUnequal<unordered_multimap>/100	1677	1141	46.98%
HashRandomUnequal<unordered_multimap>/512	10386	7036	47.61%
HashRandomUnequal<unordered_multimap>/4096	173807	119391	45.58%
HashRandomUnequal<unordered_multimap>/32768	2898405	1529710	89.47%
HashRandomUnequal<unordered_multimap>/100000	27441112	18602792	47.51%
HashRandomUnequal<hash_multimap>/1	18.9	11.8	60.17%
HashRandomUnequal<hash_multimap>/10	138	101	36.63%
HashRandomUnequal<hash_multimap>/100	1613	1154	39.77%
HashRandomUnequal<hash_multimap>/512	10385	7178	44.68%
HashRandomUnequal<hash_multimap>/4096	171718	120115	42.96%
HashRandomUnequal<hash_multimap>/32768	3352231	1510245	121.97%
HashRandomUnequal<hash_multimap>/100000	26532471	19209741	38.12%
HashRandomEqual<unordered_multimap>/1	16	9.4	70.21%
HashRandomEqual<unordered_multimap>/10	126	89.2	41.26%
HashRandomEqual<unordered_multimap>/100	1644	1133	45.10%
HashRandomEqual<unordered_multimap>/512	10532	7183	46.62%
HashRandomEqual<unordered_multimap>/4096	174580	120029	45.45%
HashRandomEqual<unordered_multimap>/32768	3031653	1455416	108.30%
HashRandomEqual<unordered_multimap>/100000	26100504	19240571	35.65%
HashRandomEqual<hash_multimap>/1	15.9	9.38	69.51%
HashRandomEqual<hash_multimap>/10	123	94.1	30.71%
HashRandomEqual<hash_multimap>/100	1645	1151	42.92%
HashRandomEqual<hash_multimap>/512	10177	7144	42.46%
HashRandomEqual<hash_multimap>/4096	172994	121381	42.52%
HashRandomEqual<hash_multimap>/32768	3045242	1966513	54.85%
HashRandomEqual<hash_multimap>/100000	26013781	22025482	18.11%
HashUnequalDifferingBuckets<unordered_multimap>/2	5.87	3.41	72.14%
HashUnequalDifferingBuckets<unordered_multimap>/10	12	3.39	253.98%
HashUnequalDifferingBuckets<unordered_multimap>/100	106	3.41	3008.50%
HashUnequalDifferingBuckets<unordered_multimap>/512	691	3.46	19871.10%
HashUnequalDifferingBuckets<unordered_multimap>/4096	6965	3.47	200620.46%
HashUnequalDifferingBuckets<unordered_multimap>/32768	91451	3.46	2642992.49%
HashUnequalDifferingBuckets<unordered_multimap>/100000	290430	3.52	8250752.27%
HashUnequalDifferingBuckets<hash_multimap>/2	5.97	3.4	75.59%
HashUnequalDifferingBuckets<hash_multimap>/10	11.8	3.54	233.33%
HashUnequalDifferingBuckets<hash_multimap>/100	105	3.54	2866.10%
HashUnequalDifferingBuckets<hash_multimap>/512	763	3.46	21952.02%
HashUnequalDifferingBuckets<hash_multimap>/4096	6862	3.4	201723.53%
HashUnequalDifferingBuckets<hash_multimap>/32768	94583	3.4	2781752.94%
HashUnequalDifferingBuckets<hash_multimap>/100000	287996	3.43	8396284.84%
```

Benchmark code:
```
#undef NDEBUG
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#include <assert.h>
#include <benchmark/benchmark.h>
#include <hash_map>
#include <random>
#include <stddef.h>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

template <template <class...> class MapType> void HashRandomUnequal(benchmark::State &state) {
    std::minstd_rand rng(std::random_device{}());
    const auto range0 = static_cast<ptrdiff_t>(state.range(0));
    vector<pair<unsigned, unsigned>> testData;
    testData.resize(range0 * 5);
    const auto dataEnd = testData.begin() + range0;
    std::generate(testData.begin(), dataEnd, [&]() { return pair<unsigned, unsigned>{rng(), 0u}; });
    std::copy(testData.begin(), dataEnd,
              std::copy(testData.begin(), dataEnd,
                        std::copy(testData.begin(), dataEnd, std::copy(testData.begin(), dataEnd, dataEnd))));
    std::unordered_multimap<unsigned, unsigned> a(testData.begin(), testData.end());
    testData.clear();
    std::unordered_multimap<unsigned, unsigned> b = a;
    next(b.begin(), b.size() - 1)->second = 1u;
    for (auto &&_ : state) {
        (void)_;
        assert(a != b);
    }
}

BENCHMARK_TEMPLATE1(HashRandomUnequal, unordered_multimap)->Arg(1)->Arg(10)->Range(100, 100'000);
BENCHMARK_TEMPLATE1(HashRandomUnequal, hash_multimap)->Arg(1)->Arg(10)->Range(100, 100'000);

template <template <class...> class MapType> void HashRandomEqual(benchmark::State &state) {
    std::minstd_rand rng(std::random_device{}());
    const auto range0 = static_cast<ptrdiff_t>(state.range(0));
    vector<pair<unsigned, unsigned>> testData;
    testData.resize(range0 * 5);
    const auto dataEnd = testData.begin() + range0;
    std::generate(testData.begin(), dataEnd, [&]() { return pair<unsigned, unsigned>{rng(), 0}; });
    std::copy(testData.begin(), dataEnd,
              std::copy(testData.begin(), dataEnd,
                        std::copy(testData.begin(), dataEnd, std::copy(testData.begin(), dataEnd, dataEnd))));
    std::unordered_multimap<unsigned, unsigned> a(testData.begin(), testData.end());
    testData.clear();
    std::unordered_multimap<unsigned, unsigned> b = a;
    for (auto &&_ : state) {
        (void)_;
        assert(a == b);
    }
}

BENCHMARK_TEMPLATE1(HashRandomEqual, unordered_multimap)->Arg(1)->Arg(10)->Range(100, 100'000);
BENCHMARK_TEMPLATE1(HashRandomEqual, hash_multimap)->Arg(1)->Arg(10)->Range(100, 100'000);

template <template <class...> class MapType> void HashUnequalDifferingBuckets(benchmark::State &state) {
    std::unordered_multimap<unsigned, unsigned> a;
    std::unordered_multimap<unsigned, unsigned> b;
    const auto range0 = static_cast<ptrdiff_t>(state.range(0));
    for (ptrdiff_t idx = 0; idx < range0; ++idx) {
        a.emplace(0, 1);
        b.emplace(1, 0);
    }

    a.emplace(1, 0);
    b.emplace(0, 1);
    for (auto &&_ : state) {
        (void)_;
        assert(a != b);
    }
}

BENCHMARK_TEMPLATE1(HashUnequalDifferingBuckets, unordered_multimap)->Arg(2)->Arg(10)->Range(100, 100'000);
BENCHMARK_TEMPLATE1(HashUnequalDifferingBuckets, hash_multimap)->Arg(2)->Arg(10)->Range(100, 100'000);

BENCHMARK_MAIN();

* Apply a bunch of code review comments from Casey.

* clang-format

* Apply @miscco's code deduplication idea for <xhash>.

* Fix code review comments from Stephan: comments and add DMIs.
2020-01-19 12:38:04 -08:00
Michael Schellenberger Costa b3598a4f0b P0122R7 <span> (#142)
Fixes #4.
2020-01-17 19:23:11 -08:00
Casey Carter e36c3bff61
Don't assume _HAS_CONDITIONAL_EXPLICIT for __INTEL_COMPILER (#424)
This change is not a statement of support for the Intel C++ compiler by the STL, so much as an attempt to not break it gratuitously.

Fixes DevCom-744112.
2020-01-17 12:53:03 -08:00
Adam Bucior d862650bd5 Support For Incomplete Types In reference_wrapper (#393)
* Implement P0357R3
* Update LLVM to get skip of libcxx\test\std\utilities\function.objects\refwrap\weak_result.pass.cpp, and exclude "// REQUIRES: c++98 || c++03 || c++11 || c++14 || c++17" as a 'magic comment'.

Co-authored-by: Billy O'Neal <billy.oneal@gmail.com>
Co-authored-by: Casey Carter <cartec69@gmail.com>
2020-01-09 13:54:20 -08:00
Daan De Meyer 31bed7ae0d system_error: Map `errc::broken_pipe` to `ERROR_BROKEN_PIPE`. (#406)
Co-authored-by: Billy O'Neal <billy.oneal@gmail.com>
2020-01-09 11:35:54 -08:00
Adam Bucior eb4a486c83 P1006R1 constexpr For pointer_traits<T*>::pointer_to() (#397)
Co-authored-by: Billy O'Neal <billy.oneal@gmail.com>
2020-01-09 10:38:13 -08:00
Daniil Goncharov 7ad0d63987 <numeric> Implement P1645R1 "constexpr for <numeric> algorithms" (#399)
Co-authored-by: Billy O'Neal <billy.oneal@gmail.com>
2020-01-08 19:23:30 -08:00
Daniel Marshall 48c7f31413 <utility> Deprecate std::rel_ops & resolve #403 (#402)
Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Billy O'Neal <billy.oneal@gmail.com>
2020-01-08 19:16:40 -08:00
Billy O'Neal 94c9f9965b
Fix std::filesystem::remove on ReFS targets (#407)
* Fix std::filesystem::remove on ReFS targets by falling back to standard delete on ERROR_NOT_SUPPORTED.

Resolves DevCom-857535.
2020-01-06 14:06:14 -08:00
Casey Carter 4d5d226a72
Implement LWG-3356 (#404)
...which renames the feature-test macro `__cpp_lib_nothrow_convertible` to `__cpp_lib_is_nothrow_convertible`. We *just* added this feature-test macro which hasn't yet shipped, and therefore want to rename it quickly - ideally before customers notice it exists. LWG has tentatively approved this issue resolution.
2020-01-06 13:05:00 -08:00
Michael Schellenberger Costa 4aaa0135d9 [ranges] Implement some range concepts (#389)
P1456R1 Move-Only Views
P1870R1 safe_range
2019-12-16 21:58:58 -08:00
Daniil Goncharov 47881a869f Define _CONSTEXPR20 (#387) 2019-12-16 21:38:20 -08:00
Nikita Kniazev e59afeab79 <iterator>: reduced parsing time (#355)
* Replaced `<istream>` include with `<iosfwd>` because `[io]stream_iterator`
  needs only `basic_[io]stream` forward declaration.
* Moved `[io]streambuf_iterator` iterator definition to `<iterator>` because
  their definition has to come when `<iterator>` is included.
* Include `<iterator>` in `<xlocmon>`, `<xlocnum>`, and `<xloctime>` as
  the `[io]streambuf_iterator` definition are required there, and `<xutility>`
  already included via other includes.

Parsing times:

| header     |          clang          |           msvc          |
|------------|-------------------------|-------------------------|
| <iterator> | 0.371 -> 0.163 (-56.1%) | 0.216 -> 0.094 (-56.5%) |
| <istream>  | 0.366 -> 0.372 ( +1.6%) | 0.215 -> 0.216 ( +0.5%) |
| <xlocmon>  | 0.358 -> 0.364 ( +1.7%) | 0.211 -> 0.211 (    0%) |
| <xlocnum>  | 0.357 -> 0.360 ( +0.8%) | 0.207 -> 0.208 ( +0.5%) |
| <xloctime> | 0.364 -> 0.370 ( +1.6%) | 0.211 -> 0.214 ( +1.4%) |
2019-12-16 17:04:28 -08:00
Adam Bucior 07e85d10c0 Remove weak_equality and strong_equality (#381)
Implement WG21-P1959 Removing `weak_equality` And `strong_equality`, working towards #64.
2019-12-13 15:00:50 -08:00
Charlie Barto 70e49a0156 Explain why invoke is implemented with a macro (#368) 2019-12-11 18:06:17 -08:00
Stephan T. Lavavej d0ff26f92e
Fix #340: <functional>: _HAS_STATIC_RTTI=0 shouldn't say typeid(void) (#375)
This calls `abort()` as there's no need to invoke the terminate handler.

(This is a virtual function, so eliminating it entirely would risk ODR
violations leading to crashes. It's much safer to provide a definition
that can't be called.)

Additionally, fix `<xlocale>` to qualify `_CSTD abort()`.
2019-12-11 16:29:43 -08:00
Stephan T. Lavavej 2428e4631f
Fix #192: <cmath>: Fuse <xtgmath.h> (#374) 2019-12-11 16:28:07 -08:00
Stephan T. Lavavej 1666b7c145
Fix #347: <shared_mutex>: Do we still need the _USING_V110_SDK71_ guard? (#373)
While we must continue to support `msvcp140.dll` running on Windows XP,
we don't need to support compiling our headers with the (removed)
`v140_xp` toolset and its corresponding old Windows SDK. Accordingly,
we can unconditionally define `shared_mutex`. (This is a C++17 feature,
but it was implemented before Standard modes, so it's not guarded by
`_HAS_CXX17`.)
2019-12-11 16:27:13 -08:00
Stephan T. Lavavej 0781d10b9d
yvals_core.h: Remove "toolset update" workaround. (#372)
Currently, we're building the STL in both our Microsoft-internal MSVC
repo and in GitHub, as we work on the migration. The MSVC repo uses a
checked-in compiler (the "toolset") to build the STL and the compiler
itself. Earlier, the checked-in toolset identified itself as
19.25.28318.97 but lacked support for `is_constant_evaluated`, so we
needed to detect that exact version number. Now, the toolset has been
updated, so this workaround is no longer necessary.

When VS 2019 16.5 Preview 2 is available in the future, we'll begin
requiring it to build the GitHub sources, at which point we'll be able
to unconditionally define `__cpp_lib_is_constant_evaluated`.
2019-12-11 16:26:38 -08:00
Billy O'Neal 991ffe57d8
Reduce stack space consumption of list<T>::insert (#366)
* Avoid burning unused stack space for a T in _List_node_insert_op. Resolves #973579 and GH-365.

* Change forward_list to follow a similar pattern for consistency.

* First round of code review feedback.
2019-12-11 12:58:44 -08:00
Billy O'Neal aa0a7a3d85
Strengthen noexcept on std::exchange, which improves codegen for many move constructors and move assignments that use std::exchange. (#364)
Works toward GH-363
2019-12-09 20:33:26 -08:00
Julie Philip James 8f9431931b Fix #249: Change <hash_map> to consistently use int = 0 SFINAE (#328)
Permanently work around DevCom-848104 by simplifying hash_meow::value_type. This is what unordered_meow::value_type already does, which is why that can already use int = 0 SFINAE.
2019-12-07 01:11:26 -08:00
SasLuca ad5b80690d Use _STD addressof(_Val), update _MSVC_STL_UPDATE (#358)
* Fix #272: `<future>: promise<_Ty&>::set_value(_Ty& _Val)` should use `_STD addressof(_Val)`
* Fix #344: `<yvals_core.h>`: Update `_MSVC_STL_UPDATE` to December 2019
2019-12-06 19:38:33 -08:00
Stephan T. Lavavej da0d8cfdef Rewrap comments in <execution>. 2019-12-06 13:45:40 -08:00
Stephan T. Lavavej ef964344a8 Improve clang-format with StatementMacros. 2019-12-06 13:45:40 -08:00
Stephan T. Lavavej 18063ce6e4 Fix #322: <filesystem>: GetVolumePathNameW linker errors for UWP developers 2019-12-06 13:45:40 -08:00
Stephan T. Lavavej 19067f6752 Reorder and rewrap yvals_core.h comments. 2019-12-04 20:21:54 -08:00
Stephan T. Lavavej bef8b56dc9 Fix #156: WG21-P0595 is_constant_evaluated() 2019-12-04 20:21:54 -08:00
Stephan T. Lavavej d9d7bd808e Fix #339: WG21-P1902 Missing Feature-Test Macros 2017-2019 2019-12-04 20:21:54 -08:00
Stephan T. Lavavej 664adab3ab Fix #335: LWG-3257 Missing feature testing macro update from WG21-P0858 2019-12-04 20:21:54 -08:00
Stephan T. Lavavej bb41688bb1 Fix #70: LWG-3199 istream >> bitset<0> fails 2019-12-04 20:21:54 -08:00
Stephan T. Lavavej b01023144a Fix #332: LWG-3266 to_chars(bool) should be deleted 2019-12-04 20:21:54 -08:00
Casey Carter d42d1cd2a5 Hide std::unreachable_sentinel_t's friends harder (#352)
Hidden friends aren't hidden in C1XX's permissive mode, so let's use an alternate mechanism to make these operators truly ADL-only. (We want to avoid checking `weakly_incrementable` for every type that is compared via `==` or `!=` with a type associated with namespace `std`.)
2019-12-04 20:20:56 -08:00
Casey Carter 40017205af Improve diagnostic for std::function<void() noexcept> (#350)
Programs that include such specializations are ill-formed, since the Standard only specifies a partial specialization of `std::function<T>` for non-`noexcept` function types `T`. The current diagnostic:
```
error C2027: use of undefined type 'std::_Get_function_impl<_Fty>'
```
is not great.

Fixes DevCom-825902.

[This is a replay of Microsoft-internal MSVC-PR-215822.]
2019-12-04 20:20:28 -08:00
Krystyna Lopez 20adb42ae3 Change return type from non-const to const (#324)
Addresses #268 by changing the implementation to match the current Standardese.
2019-12-04 20:17:48 -08:00
S. B. Tam 1d39dfac99 Implement P1690R1 Refining Heterogeneous Lookup For Unordered Containers (#341)
* Implement P1690R1 Refining Heterogeneous Lookup For Unordered Containers

* Mark P1690R1 as implemented in yvals_core.h.
2019-12-02 20:34:31 -08:00
Casey Carter 1e8b8d4eef
[range.iter.ops], default_sentinel, and unreachable_sentinel (#329)
Implements iterator primitive operations `std::ranges::advance`, `std::ranges::next`, `std::ranges::prev`, and `std::ranges::distance`; as well as `std::default_sentinel` and `std::unreachable_sentinel`.

This change reworks the STL's iterator unwrapping machinery to enable unwrapping of C++20 move-only single-pass iterators (and `if constepxr`s all the things). Consequently, `_Iter_ref_t`, `_Iter_value_t`, and `_Iter_diff_t` resolve to `iter_reference_t`, `iter_value_t`, and `iter_difference_t` (respectively) in `__cpp_lib_concepts` (soon to be C++20) mode. This change necessitates some fixes to `unique_copy` and `_Fill_memset_is_safe` which both assume that `_Iter_value_t<T>` is well-formed for any iterator `T`. (`iter_value_t<T>` does not have that property: it is only well-formed when `readable<T>`.)

I notably haven't unified `default_sentinel_t` with `_Default_sentinel` out of an abundance of paranoia. Our `move_iterator` is comparable with `_Default_sentinel`, which is not the case for `std::default_sentinel`.

Drive-by:
* This change `if constexpr`-izes `unique_copy`.
2019-12-02 15:32:14 -08:00
Billy O'Neal a4034496ee
Use on/off SFINAE in std::function when not blocked by compiler bugs. (#244)
Xiang Fan of the C1XX frontend team reported that this improved throughput in a customer submitted benchmark.
2019-12-02 14:36:53 -08:00
Stephan T. Lavavej 8f4c816377
Simplify thread0.cpp and xthrow.cpp. (#320)
* Simplify thread0.cpp and xthrow.cpp.

I verified with `#error` that these files are always compiled with
`_HAS_EXCEPTIONS=1`.

thread0.cpp
Include only necessary headers.

Move the lookup tables within `_STD_BEGIN` to avoid repeated `_STD`
qualification. They're `static`, so this doesn't affect bincompat.

Add trailing commas for readability.

Make `codes` a table of `errc` so we don't need to cast each value.

Mark `_Throw_Cpp_error` as `[[noreturn]]`, matching its declaration
in the header. (No bincompat effect.)

Use `_THROW` for consistency. (Even though exceptions are enabled,
we conventionally use this in `src`.)

`system_error` is a type, so we don't need to `_STD` qualify it.

`static_cast<int>` the `errc`, once.

xthrow.cpp
Coalesce headers. Coalesce `std` regions.

Remove unnecessary comments.

Mark value parameters as const.

* Add constexpr.
2019-11-20 17:10:23 -08:00
Charlie Barto 1980e1a295 Add P0553R4 and P0556R3 to <bit> (with D1956 rename) (#310)
Resolves #25 and resolves #26. Currently active for Clang and EDG, but not C1XX.
2019-11-18 23:27:19 -08:00
Adam Bucior c5aaa28e52 P1612R1 Relocating endian To <bit> (#305)
Resolves  #61.
2019-11-18 23:13:38 -08:00
Julie Philip James 580e61a5f5 Marked _Doraise() functions as override (#302)
Improves #207.
2019-11-15 17:20:06 -08:00
S. B. Tam 6a96a3b0bc STL: Remove !_HAS_EXACT_COMPOUND_REQUIREMENT fallback (#301)
Fixes #299.
2019-11-15 17:16:01 -08:00
Krystyna Lopez 1648f3de58 <algorithm>: Use iter[idx] for clarity (#289)
Fixes #278.
2019-11-15 17:07:14 -08:00
Stephan T. Lavavej bfb96b1e12
Update __cpp_lib_concepts (see WG21-P1902). (#287)
This feature-test macro is being extensively queried, so we're updating it with high priority ahead of the other feature-test macro changes in this paper.
2019-11-11 21:25:16 -08:00
Michael Schellenberger Costa 10f1c819cc Use unqualified function calls for valarray (#286)
* Use unqualified function calls for valarray

The transcend functions require that the function is applied unqualified to each element

* Add comments to unqualified calls.

Fixes #285.
2019-11-11 21:23:24 -08:00
Daniel Marshall 1de980c54b P0340R3 SFINAE-Friendly underlying_type (#284)
Resolves #11. Implemented unconditionally.
2019-11-11 21:20:08 -08:00
Daniel Marshall eba6a71983 P0631R8 <numbers> Math Constants (#261)
Resolves #29.
2019-11-11 21:17:34 -08:00
Michael Schellenberger Costa f9b1dccd12 P0738R2 istream_iterator Cleanup (#246)
This change is unconditional.

Resolves #35.
2019-11-07 14:52:26 -08:00
Stephan T. Lavavej 5add7295ed
Enable clang-format AlignConsecutiveMacros. (#269)
* Update `.clang-format` defaults.

* Enable `AlignConsecutiveMacros`, newly supported by clang-format 9.
We often followed this style before using clang-format, and I believe
that it produces generally positive changes.

* Apply clang-format changes.

* Replace `_FITS` and `_NEXT_ALIGN` macros. clang-format didn't damage
them, it just brought them to my attention. These macros weren't
improving clarity, and the code is more systematic without them.
(For the time being, I have refrained from further overhauling the
metaprogramming here.)
2019-11-07 14:43:51 -08:00
Daniel Marshall 9d635aaef7 Use consistent phrasing of required standard mode (#252)
Fixes #250.
2019-11-05 13:12:34 -08:00
SumanjaliDamarla d0d724fb91 Update _MSVC_STL_UPDATE to 201911L (#253)
Fixes #247.
2019-11-04 11:36:54 -08:00
Michael Schellenberger Costa 3b0a1c9cfa Consistently use "int = 0" SFINAE (#226)
Fixes #187.

Add TRANSITION comments for #248 and #249, blocked by compiler bugs.

Add `_Enabled` names. When we don't have `enable_if_t`, this makes the
template parameter's purpose clearer. When we do have `enable_if_t`
but without `= 0`, this makes it somewhat clearer that we haven't
forgotten the default argument (it's simply elsewhere).
2019-11-01 18:15:37 -07:00
Daniel Marshall 28ec9a3295 P1209R0 erase_if(), erase() (#236)
Resolves #55.

* Deprecate experimental::erase

* Implement P1209R0

* Update yvals_core.h

* Update deprecations and remove <experimental/xutility>

* move and reorder erase/erase_if

* moved _Erase and remove and friends to <xmemory>

* Consistently place erase_if() definitions.
2019-11-01 14:32:39 -07:00
Casey Carter 1d094330aa
<compare> implement == for comparison categories (#242)
WG21-P1614 "The Mothership has Landed" added `==` operators to the comparison category types (`weak_equality`, `strong_equality`, `partial_ordering`, `weak_ordering`, and `strong_ordering`) defined in `<compare>`. This PR implements those operators to bring the comparison category types up to spec once again. It also implements P1614R2's removal of operators that rewrite into calls to `operator==(X, nullptr_t)` for each comparison category type `X`.

Drive-by changes:
* Move the TODO list of tasks for WG21-P0768 "Library Support for the Spaceship (Comparison) Operator" completion out of `<compare>` and into microsoft/STL#64
* Remove the `#if 0 // Not yet implemented` block from `<compare>`
2019-10-31 17:37:56 -07:00
Casey Carter b9eb320940
Update required compiler versions (#231)
* Update required compiler versions

Update required version of MSVC to VS 2019 16.4p2, and Clang/LLVM to 9.0.0.

* Tell `<yvals_core.h>` that Clang 9 implements `consteval` (WG21 hasn't yet defined a feature-test macro for `consteval`)
* Tell `<atomic>` that Clang 9 implements the `__iso_volatile_load64` intrinsic on x86

* Update mentions of VS version in `README.md`
2019-10-29 20:40:09 -07:00
Billy O'Neal f4f3acde83
Avoid self-move-assign of all elements in vector when erasing an empty range. (#228)
Resolves DevCom-776568.
2019-10-28 19:41:58 -07:00
Billy O'Neal 5bf80b41d1
Use casts for most common atomic cases (#227)
Resolves #85 / DevCom-706195

Casey applying the new atomic implementation fixed us breaking the
strict aliasing rules, but the memcpy is causing a code size regression
for non-`/Oi` customers. This change should restore code size for the
most common uses of atomic, which are `atomic<integral>` and
`atomic<pointer>`.
2019-10-28 15:49:58 -07:00
Julie Philip James 04cf94886a Changed TODO comments to TRANSITION comments (#221)
Fixes #200.
2019-10-27 14:12:14 -07:00
Christian Deneke 99b75ab51d Move nlsdownlevel.h into winapinls.cpp (#220)
Fixes #188.
2019-10-27 14:04:30 -07:00
Nathan Ward fb7dba4b19 P0655R1 visit<R>() (#201)
Implements P0655R1 `visit<R>()` 

Resolves #31.
2019-10-25 18:48:15 -07:00
Krystyna Lopez a69a00e33b Fix #218 - remove public redundancy (#219) 2019-10-25 11:26:59 -07:00
Billy O'Neal 6b0238d703
Changes made from update to clang-format to 9.0.0. (#205) 2019-10-24 16:47:28 -07:00
Nathan Ward 447f879b13 LWG-2899 is_(nothrow_)move_constructible and tuple, optional, and unique_ptr (#193)
Resolves #68.
2019-10-22 17:50:05 -07:00
Nathan Ward a7d9526804 LWG-3158 tuple(allocator_arg_t, const Alloc&) should be conditionally explicit (#195)
Resolves #69.
2019-10-22 17:25:38 -07:00
Stanislav Ershov f05c358509 P0767R1 Deprecating is_pod (#179)
Resolves #36.
2019-10-22 17:17:11 -07:00
Nathan Ward 379e61781a P0356R5 bind_front() (#158)
Resolves #13.
2019-10-22 17:15:35 -07:00
Nathan Ward 957fe99f41 P0966R1 string::reserve() should not shrink (#176)
Fixes #42.
2019-10-17 16:06:27 -07:00
Stephan T. Lavavej 53cdb9f8a8
Fix #94 and remove compiler bug workarounds. (#175)
* Properly comment "Tukey's ninther".

* Remove workarounds for VSO-946746.

VSO-946746 "conditional explicit(bool) doesn't work with /clr:pure"
was fixed on 2019-07-23, and should be available in
VS 2019 16.4 Preview 1.

* Remove workarounds for VSO-433486.

VSO-433486 "_Count / 2 inside while (0 < _Count) loop is not
transformed into a simple shift" was fixed on 2019-08-27
and should be available in VS 2019 16.4 Preview 2.

Some shifts are still necessary, and are now commented.

* This mirrors a Microsoft-internal PR:
https://devdiv.visualstudio.com/DevDiv/_git/msvc/pullrequest/207988
2019-10-15 16:49:36 -07:00
Casey Carter 6aa3b02fde
Cleanup <any> and allow overaligned types (#173)
`<any>` cleanup:

* Prefer variable templates to class templates
* Prefer `if constexpr` to tag dispatch
* Function pointers may be `noexcept` in C++17
* Remove the layer of "symbolic member name" functions to improve debug codegen
* Conventionally use `enable_if_t<conjunction_v<meow, woof>` instead of `enable_if_t<meow::value && woof::value>`
* Apply `_NODISCARD` and `noexcept` to internal functions as appropriate
* Allow overaligned types, which are properly handled by the `_Big` representation

Resolves [DevCom-724444](https://developercommunity.visualstudio.com/content/problem/724444/meow.html).
2019-10-15 13:16:34 -07:00
Billy O'Neal 0d95d86ee7
Add back the missing unique_ptr swap (#170)
Resolves DevCom-754487 / VSO-1000729
2019-10-11 14:39:53 -07:00
Stephan T. Lavavej 712b7971bd
Update comments to follow custom autolink syntax (#168)
* Use custom autolinks.

* Also update .clang-format.

* Use ArchivedOS.
2019-10-11 13:43:06 -07:00
Casey Carter f565496875
Workaround clang __is_base_of bug in <type_traits> (#167)
Clang's `__is_base_of` intrinsic incorrectly handles some corner cases involving incomplete union types before LLVM 9. Workaround by guarding with `__is_class`.
2019-10-09 18:21:10 -07:00
Stephan T. Lavavej 50f343b458
Implement LWG 3268's PR to fix #150. (#151)
This is a back-compat fix for users who were saying things like
`std::memory_order::memory_order_relaxed`. As there is nothing
especially problematic about such usage, and LWG's ultimate resolution
is unknown, I'm not deprecating these enumerators at this time. If and
when this is voted into the WP in the deprecated clause, then we can
add deprecated attributes.

This mirrors a Microsoft-internal PR:
https://devdiv.visualstudio.com/DevDiv/_git/msvc/pullrequest/205250
2019-10-01 16:04:24 -07:00
Michael Schellenberger Costa cf55d69c40 P1227R2 Signed std::ssize() (#130)
Fixes #56.
2019-09-26 20:10:40 -07:00
Michael Schellenberger Costa 13fa3d8b0e P1357R1 is_bounded_array, is_unbounded_array (#127)
Fixes #58.
2019-09-26 19:54:23 -07:00
Andrew Fogarty 3ed27b95ce P0439R0 enum class memory_order (#124)
Fixes #17.
2019-09-26 19:51:00 -07:00
Casey Carter 1dcac20d28
Refuse to allow clang to include coroutine headers (#136)
Resolves #105.
2019-09-26 10:45:58 -07:00
Charlie Barto ff7d132b2e
implement P0325R4 to_array (#135) 2019-09-25 19:30:31 -07:00
Casey Carter 62482a6ddd
Fix regex tokenizing bug (#131)
We skip a non-match character in `regex_iterator::operator++` after a zero-length match to avoid repeat matches, resulting in incorrect behavior when tokenizing with a regex to match the delimiters between tokens.

Fixes [DevCom#733051](https://developercommunity.visualstudio.com/content/problem/733051/splitting-a-string-with-a-regex-returns-seemingly.html).
2019-09-24 15:14:39 -07:00
Billy O'Neal 44720cd5f6
Do size modifications after iterator transfer strategy selection (#129)
This was the cause of the DevCom reported bug:

https://developercommunity.visualstudio.com/content/problem/739698/vc-163-listsplice-bug.html

where we would choose the incorrect strategy to transfer iterators if and only if the number of transferred iterators was exactly half of the container.

This change replicates internal [PR 203902](https://devdiv.visualstudio.com/DevDiv/_git/msvc/pullrequest/203902)
2019-09-24 03:23:13 -07:00
Casey Carter da76ab2d5f
basic_string_view's non-member begin/end should take basic_string_view by value (#119)
... as the working draft requires. Test coverage failed to detect this issue due to [an overload resolution bug in MSVC](https://developercommunity.visualstudio.com/content/problem/739010/overload-resolution-fails-to-select-deleted-overlo.html).

Drive-by: Remove the "accepts rvalues" bit from the comment in `begin` which caused the confusion that gave rise to #104. Hopefully it is now glaringly obvious that `begin` and `end` accept both lvalues and rvalues.

Resolves #104.
2019-09-20 12:39:25 -07:00
practicalswift 7f65140761 Fix typos (#96)
* Fix typos

* Run clang-format on touched files

* Revert clang-format damage
2019-09-17 21:45:12 -06:00
Michał Cichoń c838a6f937 Reflect directory structure of includes in ${PROJECT_BINARY_DIR}/out/inc (#98)
Configured headers were flattened during configuration. This patch
keep original directory structure.

For example without this for 'deque` is replaced by `experimental/deque`.
2019-09-17 08:01:08 -07:00
Casey Carter 92508bed63 Update "old" range types
* `array`, `basic_string`, `basic_string_view`, `valarray`, and `vector` (`span` is not yet implemented) model `contiguous_range` by defining the nested type `iterator_concept` to `contiguous_iterator_tag` in `iterator` and `const_iterator`, and specializing `pointer_traits` for those types (to fulfill `contiguous_iterator`'s `std::to_address` requirement)

* `basic_string_view` (Ditto, no `span` yet) models the exposition-only *`forwarding-range`* concept (which indicates that the validity of iterators is not bound to the lifetime of the range) by defining hidden-friend overloads of `begin` and `end` that accept rvalues

* Drive-by:
  * mark the `_Unfancy` internal helper function `[[nodiscard]]`
  * Remove redundant `_Can_begin` requirement from `std::ranges::_Begin::_Cpo::_Choose`

* Add test coverage to `devcrt/P0896R4_ranges_range_machinery`:
  * tighten up `test_std_container`:
    * `data` and `cdata` reject rvalue arguments since the returned pointer could potentially dangle (`contiguous_range` codepaths were lacking coverage)
    * the `size_type` of a standard container can be other than `std::size_t` when using fancy pointers
    * we should enforce that each container's iterator type models the expected concept
  * Add test coverage to ensure that contiguous standard library containers model `contiguous_range` even when using an "old" fancy pointer type that does not model `contiguous_iterator`
2019-09-15 18:41:16 -07:00
Casey Carter 91d4b8fb89 _Has_class_or_enum_type concept should admit unions
Unions have "class type", despite that `is_class_v` is false for unions. Fixes a bug in which the behavior of `std::ranges::swap` cannot be customized for union types.
2019-09-12 12:16:34 -07:00
Casey Carter fc0ad927e9 Add <ranges>, inadvertently ommitted from #82
I experimented with different methods of preparing the dual checkin PR, and chose the wrong one.
2019-09-11 18:26:05 -07:00
Casey Carter 6fe5ae883f Suppress warning C4180 STL-wide (#84)
C4180 "qualifier applied to function type has no meaning; ignored" is emitted from `std::remove_reference<T>` when `T` is a function type or reference to such after applying the changes in #82. We could suppress it locally, but the warning is extremely low-value for the STL in general so let's simply suppress it globally.
2019-09-10 20:50:35 -07:00
Billy O'Neal 04cea50320
Implement load(8 bytes) with a 64 bit read on x86 (#87)
This depends on compiler support that will first ship in Visual Studio 2019 16.4, so it's guarded to allow the build to work with current preview releases.

Resolves https://developercommunity.visualstudio.com/content/problem/274938/index.html

Replays VSO PR 199513, this is the last substantial change I hope to do before we can work wholly in GitHub.
2019-09-10 19:46:22 -07:00
Casey Carter c5e2e3f799 Ranges <range> machinery
* Implements a selection of support machinery in `std::ranges` and adds the `<ranges>` header. Primarily consists of the range access customization point objects:
  * `ranges::begin`
  * `ranges::end`
  * `ranges::cbegin`
  * `ranges::cend`
  * `ranges::rbegin`
  * `ranges::rend`
  * `ranges::crbegin`
  * `ranges::crend`
  * `ranges::size`
  * `ranges::empty`
  * `ranges::data`
  * `ranges::cdata`

  and range concepts:

  * `ranges::range`
  * `ranges::output_range`
  * `ranges::input_range`
  * `ranges::forward_range`
  * `ranges::bidirectional_range`
  * `ranges::random_access_range`
  * `ranges::contiguous_range`
  * `ranges::sized_range`
  * `ranges::view`
  * `ranges::common_range`

  and the associated type aliases:

  * `ranges::iterator_t`
  * `ranges::sentinel_t`
  * `ranges::range_value_t`
  * `ranges::range_reference_t`
  * `ranges::range_difference_t`
  * `ranges::range_rvalue_reference_t`

* Adds `<ranges>` - which is mostly empty since the support machinery is defined in `<xutility>` so as to be visible to `<algorithm>`

* Annotates [P0896R4](https://wg21.link/p0896r4) as partially implemented in the "`_HAS_CXX20` directly controls" section of `<yvals_core.h>`.

* Touches `<regex>`, `<set>`, and `<unordered_set>` to add partial specializations of `ranges::enable_view` for `match_results` and `(unordered_)?multi?set` as mandated by the WD to override the heuristic.

* Partially implements [P1474R1 "Helpful pointers for `ContiguousIterator`"](https://wg21.link/p1474r1):
  * Push `pointer_traits` from `<xmemory>` and `to_address` from `<memory>` up into `<xutility>`
  * Add `to_address` expression requirement to `contiguous_iterator` concept, and update `P0896R4_ranges_iterator_machinery` appropriately
  * Implement the changes to `ranges::data` (but not `view_interface` since it isn't yet implemented)

* Drive-by:
  * Simplify the definition of `pointer_traits::_Reftype` by eschewing `add_lvalue_reference_t`.
  * Strengthen `reverse_iterator`'s constructors and `make_reverse_iterator` so `ranges::rbegin` and `ranges::rend` can be `noexcept` in more cases
  * Since we're using `_Rng` as the template parameter name for models of `std::ranges::range`, rename a local variable `_Rng` to `_Generator` in `<random>`
2019-09-09 15:31:26 -07:00
Billy O'Neal ace0f6a53f
Remove need for user to specify triplet, and enable ARM and ARM64 build (#80)
* Remove the need to specify the target architecture by testing CMAKE_CXX_COMPILER_ARCHITECTURE_ID.

This is somewhat fragile because it's documented as an internal-to-cmake variable, but FindBoost.cmake has used it 'effectively forever' so I'm not too concerned.

* Make ARM and ARM64 work, and use CMAKE_CXX_STANDARD_LIBRARIES for kernel32.lib.
2019-09-06 19:23:11 -07:00
Billy O'Neal 892f6f580a
Remove incorrect noexcept from _Buyheadnode in <list>. (#77)
Replicates https://devdiv.visualstudio.com/DevDiv/_git/msvc/pullrequest/200975
2019-09-05 21:03:29 -07:00
Billy O'Neal cd5aeb7e65
Apply useful CMake changes from the subninja attempt that work on their own (#5)
* Affirmatively set _HAS_OLD_IOSTREAMS_MEMBERS=1 to make intellisense in "Open Folder" happy.

* Use add_library(STATIC) and STATIC_LIBRARY_OPTIONS for implib smashing instead of add_custom_command et al.

* Include headers in some of the generated targets so they show up in "open folder" et al.

* Extract the target architecture from VCPKG_TARGET_TRIPLET.

* Add .vs and out/ to .gitignore as VS's open folder creates these.

* Don't link an exe in try_compile.

* Add CMakeSettings.json to make VS happy.
2019-09-05 12:29:04 -07:00
Stephan T. Lavavej 219514876e Initial commit. 2019-09-04 15:57:56 -07:00