STL Features and Fixes in VS 2017 15.8
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/.
- Implemented floating-point
from_chars()in C++17 <charconv>. It’s approximately 40% faster than the CRT’s
- Implemented C++20 feature-test macros in the compiler and STL (except for
__has_cpp_attributewhich will be implemented in the future). The feature-test macros are always provided regardless of the Standard mode option (
/std:c++17etc.) – 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.
- Added officially supported hooks to allow user iterator type interaction with iterator debugging, already in use by the Guidelines Support Library. See
gsl::spanfor an example implementation of the following customization points, or the type
_String_view_iteratorin the internal header
The customization points are, given a
const user_iterator_type cit; and a
- 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 the
- For random-access iterators, verifies that
cit + offis 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_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 by
gsl::span). If this member is not present, it defaults to false.
- Returns an “unchecked” or “unwrapped” iterator denoting the same element as
cit. This will be called by the standard library after a
_Verify_offsetcall, or if
it._Seek_to(return value from
- Moves the position of the “wrapped” or “checked” iterator
itto the position of the “unwrapped” / “unchecked” iterator supplied. This is generally not intended to perform range checks. This allows algorithms that return iterators like
std::fill_nto 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):
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.
- Implemented Library Issues 2510, 2729, and 2958 for
tuple, constraining their assignment operators. This implementation contained a minor regression affecting assignments to
std::pairfrom a type that implicitly converts to
std::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 to
std::pairis a workaround.
- Because user iterators can now officially participate in the iterator debugging system, the
_SCL_SECURE_NO_WARNINGSfamily of warnings has been removed. The previously-pseudo-documented struct
_Is_checked_helperremains present in order to avoid breaking user specializations, but it is no longer used by the library directly.
num_getoverloads to store default values in the event of a failed parse, as the standard requires.
- Fixed incorrect values
- 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_filebufwould 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
_isleadbytelater in processing, corrupting the state of the
- Fixed conditions where one could form a corrupted
stringstream) by forcing it to attempt to represent a string of more than
INT_MAXsize restriction unfortunately must remain due to ABI compatibility, but at least we now consistently enforce that restriction.
std::wsto 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_moneywhere a narrowed
wchar_twas emitted instead of the proper raw
- Fixed creating an
istreambuf_iterator::proxyreturning the value stored in the proxy rather than returning the value one would expect from a copied
- Fixed a case where
unsigned intto do intermediate calculations even when
unsigned intcould not properly store the intermediate values.
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::asyncthat 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.
recursive_directory_iterator::disable_recursion_pending()not being reset after an increment operation.
- Fixed a long-standing bug that caused
aligned_storageto treat requests for alignment greater than
alignof(max_align_t)as requests for alignment equal to
alignof(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 of
aligned_storage. As an interim solution until a future ABI-breaking release, compilation of programs that use highly-aligned
aligned_storageproduces a compile error explaining this issue and asking the user to define either
_ENABLE_EXTENDED_ALIGNED_STORAGEto request the conforming-but-potentially-ABI-breaking behavior, or
_DISABLE_EXTENDED_ALIGNED_STORAGEto request the previous incorrect-but-ABI-safe behavior.
Performance and Throughput Improvements
- Fixed iterator wrappers like
reverse_iteratordefeating 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 to
reverse_iterator<int *>instead of staying a
reverse_iterator<vector::iterator>as in previous releases.
- Changed several calls of
basic_string::push_backfor micro-perf improvements in iostreams machinery.
- Implemented a fast path for binary I/O in iostreams, quadrupling bulk I/O performance.
_NOEXCEPTand other internal non-Standard macros.
- Increased readability by consistently using
nullptrin 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 (email@example.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).