Repository navigation
Make the vocabulary types at least as noexcept as MSVC STL - #92
Open
jmgilbert2 wants to merge 1 commit into
Open
jmgilbert2 wants to merge 1 commit into
jmgilbert2 wants to merge 1 commit into
Conversation
Exception specifications of optional, expected/unexpected, unique_ptr, weak_ptr/enable_shared_from_this, function/fixed_function, variant's hash, construct_at/destroy_at/align and eastl::allocator/dummy_allocator now match or exceed MSVC STL 14.51 in C++17 and latest. Conditional specs copy MSVC's conditions with EASTL traits (variant's hash uses a small variant_is_nothrow_hashable trait, like MSVC's _Is_nothrow_hashable). - function and fixed_function: move construction and move assignment are noexcept with the current small-buffer storage rule (the in-place move helper was already noexcept), as decided for this pass. - variant(in_place_index_t, initializer_list, args...) is unconditionally noexcept: MSVC's spec there is is_constructible_v, which is always true under its constraint. - expected::value_or/error_or use is_nothrow_copy/move_constructible && is_nothrow_constructible instead of is_nothrow_convertible, which gives the same result for these convertible types without EASTL's is_nothrow_convertible C4244 narrowing warning. Only exception specifications change; no code generation changes. Tests are static_asserts that fail on the previous headers. 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.
Part A3 of the noexcept pass: EASTL's vocabulary types become at least as noexcept as MSVC STL 14.51, in C++17 and latest. Exception specifications are the only change, so no generated code changes.
Changed (about 48 unconditional and 89 conditional specs)
optionalandexpected/unexpected: constructors, assignments,emplace, comparisons,value_or/error_or,make_optional.functionandfixed_function: move construction and move assignment are now noexcept, keeping the current small-buffer storage rule (the decided option (a)). The in-place move helper was already noexcept.unique_ptr::operator*(conditional) andoperator[].weak_ptr::reset/swapandweak_from_this.construct_at,destroy_at,align.eastl::allocatoranddummy_allocatorconstructors, assignment,deallocate,get_name/set_name,==/!=. This also makes containers' default constructors noexcept, through their existing conditional specs.hash<monostate>andhash<variant>.hash<variant>uses a smallvariant_is_nothrow_hashabletrait, like MSVC's_Is_nothrow_hashable.Decisions to review
variant(in_place_index_t, initializer_list, args...)is now unconditionally noexcept. MSVC's spec there isnoexcept(is_constructible_v<...>)(<variant>line 990), which is always true under its constraint; the sibling constructors useis_nothrow_constructible_v. With exceptions on, a throwing element constructor terminates, as it does on MSVC. Reverting to the correct condition is a one-line change.expected::value_or/error_oruseis_nothrow_copy/move_constructible && is_nothrow_constructible<T, U>instead ofis_nothrow_convertible. The result is the same for these convertible types. EASTL'sis_nothrow_convertibleemits C4244 on narrowing conversions, which is a separate trait issue.Still pending
hash<variant<int, ...>>reach MSVC's answer once the function-object part of this pass (A1) lands. Their specs here are already correct.Testing
static_assertblocks in TestOptional, TestExpected, TestSmartPtr, TestFixedFunction, TestFunctional, TestMemory, TestAllocator and TestVariant. All of them fail to compile on master.noexcept(expr)against MSVC STL with cl and clang-cl in C++17 and latest. Every mismatch went to 0, apart from the variant items listed under "Still pending".🤖 Generated with Claude Code