15.7 was our first feature complete C++17 library (except floating-point <charconv>), and in 15.8 we have addressed large numbers of outstanding bugs. As usual, we’ve maintained a detailed list of the STL fixes that are available. Visual Studio 2017 15.8 is available at https://visualstudio.microsoft.com/vs/.
New Features
- Implemented floating-point
from_chars()
in C++17 <charconv>. It’s approximately 40% faster than the CRT’sstrtod()
/strtof()
. - Implemented C++20 feature-test macros in the compiler and STL (except for
__has_cpp_attribute
which will be implemented in the future). The feature-test macros are always provided regardless of the Standard mode option (/std:c++14
vs./std:c++17
etc.) – that is, individual feature-test macros are defined (or not) according to the Standard mode option and fine-grained options, but there’s no option for enabling or disabling feature-test macros in their entirety. - Implemented
std::is_aggregate
. - Added officially supported hooks to allow user iterator type interaction with iterator debugging, already in use by the Guidelines Support Library. See
gsl::span
for an example implementation of the following customization points, or the type_String_view_iterator
in the internal header<xstring>
.
The customization points are, given aconst user_iterator_type cit
; and auser_iterator_type it
:_Verify_range(cit, cit)
- Requests that the iterator type check that the parameters form a valid [First, Last) range iterator pair. The standard library provides a version for pointers under
_ITERATOR_DEBUG_LEVEL != 0
. We strongly recommend this customization point be implemented as a “hidden friend function”, as demonstrated in thegsl::span
example. cit._Verify_offset(difference_type off)
- For random-access iterators, verifies that
cit + off
is a valid iterator. Typically used to provide better diagnostics of the form “the iterator range passed to this algorithm was invalid” rather than “the iterator was incremented off the end of the range”. static constexpr bool user_iterator_type::_Unwrap_when_unverified
- Declares to the standard library whether an iterator type wants to be “unchecked” or “unwrapped” even if it can’t be verified in advance by
_Verify_range
or_Verify_offset
. For example, the standard containers set this to true if and only if_ITERATOR_DEBUG_LEVEL == 0
. This allows an iterator type to request range checks even in release builds (as desired bygsl::span
). If this member is not present, it defaults to false. cit._Unwrapped()
- Returns an “unchecked” or “unwrapped” iterator denoting the same element as
cit
. This will be called by the standard library after a_Verify_range
or_Verify_offset
call, or if_Unwrap_when_unverified
is true. it._Seek_to(cit)
/it._Seek_to(return value from
_Unwrapped()
)- Moves the position of the “wrapped” or “checked” iterator
it
to the position of the “unwrapped” / “unchecked” iterator supplied. This is generally not intended to perform range checks. This allows algorithms that return iterators likestd::fill_n
to form their return values without needing each iterator operation in the body of the algorithm to be subject to debugging checks.
- The header structure of the STL was changed to allow use of a subset of the library in conditions where the user can’t link with msvcp140.dll, such as driver development. (Previously the hard dependency on msvcp and pragma detect mismatch were injected by our base configuration header included by everything.) The following headers are now considered “core” and don’t inject our runtime dependencies (though we do still assume some form of CRT headers are present):
- <cstddef>
- <cstdlib>
- <initializer_list>
- <ratio>
- <type_traits>
We aren’t actually driver developers ourselves and are interested in feedback in this area if there are things we can do to make these more usable in constrained environments.
Correctness Fixes
- Implemented Library Issues 2510, 2729, and 2958 for
pair
andtuple
, constraining their assignment operators. This implementation contained a minor regression affecting assignments tostd::pair
from a type that implicitly converts tostd::pair
. We’ve fixed that regression for VS 2019 16.0 and are planning to backport the fix to VS 2017 15.9. In the meantime, if you encounter that compiler error, explicitly converting tostd::pair
is a workaround. - Because user iterators can now officially participate in the iterator debugging system, the
_SCL_SECURE_NO_WARNINGS
family of warnings has been removed. The previously-pseudo-documented struct_Is_checked_helper
remains present in order to avoid breaking user specializations, but it is no longer used by the library directly. - Changed
num_get
overloads to store default values in the event of a failed parse, as the standard requires. - Fixed incorrect values
numeric_limits<integral>::is_modulo
andnumeric_limits<floating-point>::tinyness_before
. - Rewrote several streambuf operations to resolve cases where the streambuf would become confused; for example, cases where
seekg(0)
would not reset the streambuf position even when the current offset was nonzero. - Fixed cases where
basic_filebuf
would become confused when set to some multibyte locales; the lead byte table was populated using the “fake POSIX support” locale function_ismbslead
, but then used the standard locale function_isleadbyte
later in processing, corrupting the state of thebasic_filebuf
. - Fixed conditions where one could form a corrupted
basic_stringbuf
(orstringstream
) by forcing it to attempt to represent a string of more thanINT_MAX
characters. TheINT_MAX
size restriction unfortunately must remain due to ABI compatibility, but at least we now consistently enforce that restriction. - Overhauled
std::ws
to Do What The Standard Says. - The off-by-default warning C4365 “conversion from ‘type_1’ to ‘type_2’, signed/unsigned mismatch” is now supported by the STL.
- Fixed a case C4365 found in
put_money
where a narrowedwchar_t
was emitted instead of the proper rawwchar_t
. - Fixed creating an
istreambuf_iterator::proxy
returning the value stored in the proxy rather than returning the value one would expect from a copiedistreambuf_iterator
. - Fixed a case where
linear_congruential_engine
would useunsigned int
to do intermediate calculations even whenunsigned int
could not properly store the intermediate values. - Fixed
linear_congruential_engine::seed()
to Do What The Standard Says. - Changed parallel algorithms’ partitioning behavior to not special case the foreground thread, improving performance in situations where the system threadpool detects an I/O bound workload and decides to oversubscribe the machine.
- Fixed a race condition in
std::async
that could cause crashes or deadlocks. - Fixed C++17
std::filesystem
‘s support .obj containing a__declspec(dllexport)
, causing unusual conditions like .exes with export tables. - Fixed
recursive_directory_iterator::disable_recursion_pending()
not being reset after an increment operation. - Fixed a long-standing bug that caused
aligned_storage
to treat requests for alignment greater thanalignof(max_align_t)
as requests for alignment equal toalignof(max_align_t)
. We can’t enable this fix unconditionally without breaking ABI since doing so changes layout of types with members whose type is a highly-aligned specialization ofaligned_storage
. As an interim solution until a future ABI-breaking release, compilation of programs that use highly-alignedaligned_storage
produces a compile error explaining this issue and asking the user to define either_ENABLE_EXTENDED_ALIGNED_STORAGE
to request the conforming-but-potentially-ABI-breaking behavior, or_DISABLE_EXTENDED_ALIGNED_STORAGE
to request the previous incorrect-but-ABI-safe behavior.
Performance and Throughput Improvements
- Fixed iterator wrappers like
move_iterator
andreverse_iterator
defeating iterator debugging optimizations. These wrappers remained “checked” even after verified by algorithms. For example,fill(someVectorOfInt.rbegin(), someVectorOfInt.rend())
will properly check the range and convert toreverse_iterator<int *>
instead of staying areverse_iterator<vector::iterator>
as in previous releases. - Changed several calls of
basic_string::append(1, ch)
tobasic_string::push_back
for micro-perf improvements in iostreams machinery. - Implemented a fast path for binary I/O in iostreams, quadrupling bulk I/O performance.
Other Changes
- Removed
_NOEXCEPT
and other internal non-Standard macros. - Increased readability by consistently using
nullptr
in the STL’s headers.
If you have any feedback or suggestions for us, let us know. We can be reached via the comments below, via email (visualcpp@microsoft.com) and you can provide feedback via Help > Report A Problem in the product, or via Developer Community. You can also find us on Twitter (@VisualC) and Facebook (msftvisualcpp).