Repository navigation
Fix SFINAE group J: C++20/23 traits, iterator adaptors, pointer_traits, span and string_view - #87
Merged
Merged
Conversation
Like std: - underlying_type<T> has no member type when T isn't an enumeration, instead of a hard error, so it can be used in SFINAE; - is_nothrow_convertible (C++20) and is_scoped_enum (C++23) are added; - unwrap_reference and unwrap_ref_decay (C++20) are added; - common_reference and basic_common_reference (C++20) are added, with C++23's convertibility rule (P2655), and match MSVC STL on 31 type combinations; - is_constant_evaluated is declared in type_traits.h, where std declares it, instead of numeric.h (which still provides it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iterator_traits: - only pointers to object types have traits (iterator_traits<void*> was a hard error), and the value type is cv-unqualified; - an iterator with the other four member types but no pointer gets pointer = void; - pointers get iterator_concept = contiguous_iterator_tag where that tag exists. reverse_iterator and move_iterator: - the converting constructor and assignment only participate if the base iterator converts (reverse_iterator<int*> from reverse_iterator<const int*> was reported constructible); - every comparison only participates if the base comparison it makes is valid, and C++20 gets operator<=>; - reverse_iterator's difference is the base difference's type, its operator-> exists only for a pointer or a base with operator->, which it calls, and both get iterator_concept; - move_iterator's converting assignment compiles: it read a protected member of another specialization. move_sentinel (C++20) is added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Like std: - pointer_traits<P> has no members when P has no element type (LWG 3545); before, element_type was P itself; - rebind<U> of a pointer class template without a rebind member is P<U, Args...>; it required the member; - pointer_traits<void*> and pointer_traits of a void pointer template are usable: pointer_to took a void& parameter, a hard error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Like std: - the constructors from a pointer and a size or an end, from a container and from a span of dynamic extent are explicit when the extent is static (span<int> converted implicitly to span<int, 3>); - the array constructors take an array of any element type that converts, so span<int> no longer accepts a const array, and the container constructors leave every array and span to them; - as_bytes and as_writable_bytes are added. first<N>, last<N> and subspan<O, N> now construct their result explicitly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Like std (C++23), basic_string can't be constructed from or assigned a nullptr: it was an argument error or a null dereference. basic_string_view(nullptr) stays an empty view, an EASTL extension TestStringView.inl tests. basic_string_view gets the C++20 iterator-pair constructor, for pointers, and C++23's explicit range constructor, which doesn't take a basic_string_view, a type that converts to const T*, or one with its own conversion to basic_string_view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
basic_string_view(nullptr) gave an empty view, an EASTL extension that TestStringView.inl tested. Like std (C++23), it's now deleted, and NULL or 0 are ambiguous: a null pointer isn't a string. A null const T* variable still gives an empty view, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
basic_string_view(const T*) gives an empty view for a null pointer instead of reading through it as std does. That stays, on purpose; the comment says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 8, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes SFINAE audit group J (cases 40, 89, 90, 104, 106, 107, 280, 294, 306, 307) and the related gaps found by sweeping the same components against MSVC STL. One commit per component.
The sweep is 69 std-vs-EASTL cases (
jcases.cppin the probe harness; cl, clang-cl and clang-cl MS mode; C++17 and latest), covering the probed cases and their siblings. On master, 52 of them differ from std. With this PR, all 69 match std.Type traits (2762431)
underlying_type<T>has no member type for a non-enumeration (it was a hard error).is_nothrow_convertible,is_scoped_enum(C++23),unwrap_reference,unwrap_ref_decay,common_referenceandbasic_common_reference.common_referencefollows the standard's steps with C++23's convertibility rule (P2655), and gives the same type as MSVC STL on 31 type combinations (references of every cv and value category, derived/base, conversions, three types, no common type).is_constant_evaluatedis declared intype_traits.h, where std declares it.numeric.hstill provides it.iterator_traits, reverse_iterator, move_iterator, move_sentinel (9307f4c)
iterator_traits<T*>only for object types (iterator_traits<void*>was a hard error), with a cv-unqualifiedvalue_type.pointermember getspointer = void, as in C++20.iterator_concept = contiguous_iterator_tagwhere that tag exists. With std iterator tags in C++17 there is none, so pointers have noiterator_conceptthere.operator<=>;iterator_concept.operator-returns the base difference's type;operator->exists only for a pointer or a base withoperator->, which it now calls.base().move_sentinelis added.pointer_traits (fd049b6)
element_typewas the pointer type itself.rebind<U>of a pointer class template without arebindmember isP<U, Args...>. Before, the member was required.pointer_traits<void*>andpointer_traitsof a void pointer template were hard errors (pointer_to(void&)). They now work, using a placeholder parameter type as MSVC does.span (78592d0)
span<int>converted implicitly tospan<int, 3>.span<int>no longer reports constructible from aconst array<int, N>&. The container constructors leave every array and span to the dedicated constructors.as_bytesandas_writable_bytes(withstd::byte).first<N>,last<N>andsubspan<O, N>construct their results explicitly.string, string_view (82ae71e, 5ea38b8)
basic_string(nullptr)and= nullptrare deleted, as in C++23. They were an argument error or a null dereference inCharStrlen.basic_string_view(nullptr)is deleted too (5ea38b8). It used to give an empty view, an EASTL extension thatTestStringView.inltested as a "user-reported regression" (since 3.08.00). A null pointer isn't a string, so like C++23 it no longer compiles, andNULLor0are ambiguous. That test now checks the deletion, and that a nullconst T*variable still gives an empty view, as before. std reads through it, which is undefined behaviour. That check is kept on purpose; 38c7986 documents it at the constructor.basic_string_view, a type that converts toconst T*, or a type with its own conversion tobasic_string_viewsuch asbasic_string.Behaviour changes to review:
span<int, 3> s = {p, 3};and the implicitspan<int>→span<int, 3>/vector<int>&→span<int, 3>conversions no longer compile (std rejects them too).string_view(nullptr),string_view(NULL)andstring_view(0)no longer compile.iterator_traits<volatile T*>::value_typeisT.reverse_iterator::operator->calls the base iterator'soperator->instead of taking&*.Not covered: the C++20
iterator_traitssynthesized from the C++17 iterator concepts, for types without member types. It needs the C++20 iterator concepts library (incrementable_traits,indirectly_readable_traits, ...), which EASTL doesn't have.Tests: TestTypeTraits, TestIterator (including the move_iterator converting assignment and a move_sentinel loop), TestMemory, TestSpan, TestStringView. Each fails to compile on master.
The other SFINAE probes (cases, xadl, alg2, cont2, cases2) change only in group J's cases.
Verification: VS 2026 cl 14.51 and clang-cl 22, C++17 and latest, Debug and Release: all 8 EASTL suites pass, no new warnings compared with master.
🤖 Generated with Claude Code