Various cleanups by StephanTLavavej · Pull Request #5924 · microsoft/STL (original) (raw)
Overview
I notice a lot of things while reviewing code, not all of which I immediately address. I spent my Thanksgiving weekend draining some of my todo backlog (I still have ~160 lines).
As a general rule, we don't like "grab bag PRs" touching lots of code, because they increase risk and are more difficult to review. (We especially dislike mixing features/fixes with unrelated cleanups.) To mitigate this, I've separated out all of the changes with behavioral impact (#5921), higher risk and MSVC-internal impact (#5922), and complicated multi-step transformations (#5923). The commits here are low risk and cleanly organized for ease of reviewing. I believe that decomposing this further wouldn't be productive.
Commits
xtime.cppdoesn't needawint.hpp, justWindows.h.validate.cppdoesn't useassert()anymore.- Followup to Add static_assert to is_sorted() for the lookup tables in validate.cpp #650 merged 2020-04-01.
// namespace$=>// unnamed namespace- We had 11 occurrences of the former, now being added to 39 occurrences of the latter.
- Fuse
_HAS_CXX20regions. - Guard
_Supports_transparencyfor_HAS_CXX23.- Followup to Introduce _Is_transparent helper trait #3736 merged 2023-06-15.
- Exclude charconv tables and test cases from VSCode search.
- They pollute search results when looking for numbers, and generally don't need to be searched. (There's a UI button to "Use Exclude Settings and Ignore Files", so this exclusion can be easily bypassed.)
- Drop unnecessary
inlinefor function templates. _STATIC_LAMBDA=>_STATIC_CALL_OPERATOR- Followup to Toolset update: VS 2022 17.14.5 Preview 1, WinSDK 26100 #5580 merged 2025-06-13.
- Add
_STATIC_CALL_OPERATORto more stateless lambdas. decltype(tzdb::leap_seconds)=>vector<leap_second>- This was a relic of an early attempt to give
tzdb::leap_secondsa fancy type.
- This was a relic of an early attempt to give
- Drop unnecessary newlines in do-while loops.
_CMPXCHG_MASK_OUT_PADDING_BITSimplies_HAS_CXX20, so_INLINE_VAR=>inlinetests/utils/stl/util.py: Remove dead code, part 1.tests/utils/stl/util.py: Remove dead code, part 2.- We're never AIX.
- psutil 2.0.0 was released on 2014-03-10. The current version is 7.1.3.
- Unwrap "strengthened" comments.
_Vb_val::_Getal()is a direct member function; all other calls omitthis->.- Use
is_null_pointer.- These locations are happy to ignore cv-quals.
- Add newlines to indicate that we don't like to interleave includes and conditionals.
- Avoid interleaving includes and conditionals.
- Include test support headers with angle brackets.
int main()=>void test()intest.compile.pass.cpp.- We don't like to have
main()functions in compile-only tests, to make it extra-clear that they aren't running any code.
- We don't like to have
- Drop
// COMPILE-ONLYintest.compile.pass.cpp.- These comments are redundant.
- Make
VSO_0000000_type_traitscompile-only.test_all_function_types()is a non-template, so we don't need to call it.- Rename
main()totest_VSO_707437()and move it up. It's testing overload resolution.
- Delete
tests/tr1/env_single.lst.- Followup to Delete <cvt/meow> #4458 merged 2024-03-15.
_USE_NAMED_IDL_NAMESPACEis unused.- IIRC this was intended for WCFB02 (the stranded vNext branch in Team Foundation Version Control).
- Consistently say "Unknown architecture".
- And don't give string literals to
#error.
- And don't give string literals to
vector_algorithms.cpp: Use#ifdef _WIN64when deciding between x64 and x86.- Qualify a
_STD _In_rangecall. <execution>:_In_range=>_In_rngto avoid shadowing.- Consistently reduce code duplication when checking intrinsic availability.
stride_viewctor: Markrange_difference_t<_Vw> _Stride_as const, to be consistent with others.<random>: Add parens when mixing left shifts with bitwise OR._Zip_fnand_Zip_transform_fnshould beclass, notstruct.- Make ranges function objects
structs when possible. steady_clock::now()should use_STL_INTERNAL_STATIC_ASSERT.- We fully control the inputs here, so users don't need these
static_asserts.
- We fully control the inputs here, so users don't need these
_STL_INTERNAL_STATIC_ASSERT(false)=>static_assert(false)for C++17 and later.- These don't impose any costs, as they occur on "can't happen" branches and we've eliminated the
_Always_falsemachinery. We should just leave them in for user code.
- These don't impose any costs, as they occur on "can't happen" branches and we've eliminated the
_STL_INTERNAL_STATIC_ASSERT(false)=>static_assert(false, "reason")in C++14 code.CMakeLists.txt: Avoid inconsistently quote-expandingVCLIBS_TARGET_ARCHITECTURE.iosptrs.cpp: Test_M_CEE_PUREinstead of_M_CEE_MIXED.- We don't need to worry about
/clr:safe. We don't need to provide a rationale.
- We don't need to worry about
- Move
stdextmacros to<exception>and limit their scope.- Followup to Remove non-Standard <hash_map> and <hash_set> #5764 merged 2025-10-10, : Remove stdext::checked_array_iterator and stdext::unchecked_array_iterator #5817 merged 2025-11-05.
xalloc.cpp: Include just<yvals.h>, we don't need<stdexcept>.yvals_core.h: Remove distinction between "directly controls" and "indirectly controls".- This was confusing for contributors to maintain, and didn't provide value.
yvals_core.h: Omit "Other deprecation warnings".- Listing this isn't useful; the messages clearly explain what Standard deprecates stuff, and how to silence them.
- Avoid using
is_constant_evaluated()to initialize const variables.- This is confusing and hazardous (witness the
elements[0]hackaround - that's always 0). The squirrelliness happens because under certain circumstances, the compiler can perform constant initialization, makingis_constant_evaluated()report that it was called at compile-time. For this reason, we should directly test it withif.
- This is confusing and hazardous (witness the
- Oops:
xkeycheck.hdoesn't have an "unnamed namespace".