Skip to content

Commit

Permalink
[aa_inplace_vector] Copying/moving an Alloc is not allowed to throw
Browse files Browse the repository at this point in the history
The Standard specifies in [allocator.requirements.general] that copy
and move operations on allocators never throw, regardless of whether
they're marked noexcept or not. And in fact `boost::interprocess::allocator`
does not mark its SMFs as noexcept. So we shouldn't check the trait
here; instead we should assume that the operations are non-throwing.
  • Loading branch information
Quuxplusone committed Aug 25, 2024
1 parent 81eeab1 commit b724a77
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions include/sg14/aa_inplace_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,11 @@ struct SG14_INPLACE_VECTOR_TRIVIALLY_RELOCATABLE_IF((sg14::aaipv::be_trivially_r
static constexpr bool CopyCtorIsNoexcept =
((std::is_nothrow_copy_constructible_v<T> &&
sg14::aaipv::has_trivial_construct<Alloc, T, const T&>::value) || (N == 0)) &&
sg14::aaipv::propagate_on_container_copy_construction<Alloc>::value &&
std::is_nothrow_copy_constructible_v<sg14::ipv_alloc_holder<Alloc>>;
sg14::aaipv::propagate_on_container_copy_construction<Alloc>::value;

static constexpr bool MoveCtorIsNoexcept =
((std::is_nothrow_move_constructible_v<T> &&
sg14::aaipv::has_trivial_construct<Alloc, T, T&&>::value) || (N == 0)) &&
std::is_nothrow_move_constructible_v<sg14::ipv_alloc_holder<Alloc>>;
sg14::aaipv::has_trivial_construct<Alloc, T, T&&>::value) || (N == 0));

// Copy-assignment follows the Lakos Rule: if the precondition might be violated, then it's not noexcept.
//
Expand Down

0 comments on commit b724a77

Please sign in to comment.