Repository navigation
Constrain any's converting and in-place constructors and assignment, like std - #84
Merged
Merged
Conversation
Both only static_asserted that the value type is copy constructible, so traits reported any as constructible and assignable from a non-copyable type. They now don't participate for a non-copyable value type, any itself or an in_place_type_t. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
They now participate only for a decayed type that is copy constructible
and constructible from the arguments; before, the first only
static_asserted and neither checked copyability. The constraint of the
initializer_list one moves from a trailing parameter into the template
parameters: after the Args pack, that parameter kept the pack from
being deduced, so any(in_place_type<T>, {list}, args...) didn't
compile.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 I (cases 315, 317) and the related in-place constructor bugs found next to it.
any's converting constructor and assignment onlystatic_asserted that the value type is copy constructible, sois_constructible<any, NonCopyable>andis_assignable<any&, NonCopyable>were true and the body failed. Each item below differed from MSVC STL, which follows the standard.Like std ([any.cons], [any.assign]):
anyor anin_place_type_t. Thein_place_type_texclusion is part of the same constraint: before,any a = in_place_type<int>;stored the tag object instead of failing to compile. The assignment now also excludesanyitself, soa = bwith a non-constanylvalue goes straight to copy assignment, with the same result;any(in_place_type<NonCopyable>)reported constructible.Also fixed:
any(in_place_type<T>, {list}, args...)didn't compile at all. Theinitializer_listconstructor's constraint was a defaulted parameter after theArgs&&...pack, and a function parameter pack that isn't last is never deduced, so any argument after the list was rejected. The constraint is now a template parameter.Tests (TestAny): the traits above,
in_place_type_tisn't convertible toany, in-place construction still works, assignment from a non-constanylvalue still copies, and in-place construction from a list followed by another argument. On master the trait asserts and the list-plus-argument construction fail to compile.The SFINAE probes change only in group I'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