You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Very conservative step towards #5311.
Prohibit at least non-integer default char traits, with escape hatch.
🎈 Floating motivation
Out of all types that we should not have supported, floats are my primary concern, especially their interaction with vectorization. We do ban them along with other unexpected types in find_meow_of:
static_assert(is_unsigned_v<_Elem>, "Standard char_traits is only provided for char, wchar_t, char8_t, char16_t, "
"and char32_t. See N4988 [char.traits]. "
"Visual C++ accepts other unsigned integral types as an extension.");
But with find/rfind the effect would be strange. I have not tried, but I expect that the unsupported 80-bit long double would fail to compile with a strange error, but normal floats and doubles would compare bitwise, resulting incorrect results for nans and negative zeros.
This use case has never existed, so everything looks like we should ban it outright.
But while we're at it, let's ban all other non-standard things, except integers.
🔢 Integers
Getting rid of non-character integers, both signed and unsigned, turned out to be much more complicated.
Specifically with filesystem test, where it uses signed char and unsigned char, and expects path conversion to work,
Looks like this is not supported. bitset constructor is defined to work as if with string or string_view, so if no explicit traits are passed, these are the default traits, that should not be defined for these odd types.
In addition P0980R1_constexpr_strings tests for weirdness, but a more modest one:
For built-in types, I'm fine with banning non-integers. There's no reason to support that complexity. But I don't think we can ban user-defined types, because users are allowed to provide a specialization of char_traits<MyCharLikeType>, right?
But I don't think we can ban user-defined types, because users are allowed to provide a specialization of char_traits<MyCharLikeType>, right?
However!
We ban directly in the primary char_traits template. Any specialization will bypass this ban.
We can additionally ban floats outside, disabling users to provide their own char_traits<long double> specialization, but I dont believe in pursuing basic_string<long double> with this level of persistence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Very conservative step towards #5311.
Prohibit at least non-integer default char traits, with escape hatch.
🎈 Floating motivation
Out of all types that we should not have supported, floats are my primary concern, especially their interaction with vectorization. We do ban them along with other unexpected types in
find_meow_of:STL/stl/inc/__msvc_string_view.hpp
Lines 916 to 918 in 8e0c6ff
But with
find/rfindthe effect would be strange. I have not tried, but I expect that the unsupported 80-bit long double would fail to compile with a strange error, but normal floats and doubles would compare bitwise, resulting incorrect results for nans and negative zeros.This use case has never existed, so everything looks like we should ban it outright.
But while we're at it, let's ban all other non-standard things, except integers.
🔢 Integers
Getting rid of non-character integers, both signed and unsigned, turned out to be much more complicated.
Specifically with filesystem test, where it uses
signed charandunsigned char, and expects path conversion to work,Let's not do this for now.
👮♂️ Offenders
Dev10_860410_bitset_ctorsstarts very normal:STL/tests/std/tests/Dev10_860410_bitset_ctors/test.cpp
Lines 59 to 66 in 8e0c6ff
Then it tests weird types:
STL/tests/std/tests/Dev10_860410_bitset_ctors/test.cpp
Lines 91 to 98 in 8e0c6ff
Culminating in this:
STL/tests/std/tests/Dev10_860410_bitset_ctors/test.cpp
Lines 124 to 126 in 8e0c6ff
Looks like this is not supported.
bitsetconstructor is defined to work as if withstringorstring_view, so if no explicit traits are passed, these are the default traits, that should not be defined for these odd types.In addition
P0980R1_constexpr_stringstests for weirdness, but a more modest one:STL/tests/std/tests/P0980R1_constexpr_strings/test.cpp
Lines 1683 to 1688 in 8e0c6ff
STL/tests/std/tests/P0980R1_constexpr_strings/test.cpp
Line 1706 in 8e0c6ff
I've added escape hatches to both tests matrices.