C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Replace an object -- but retain old object if new object fails to construct

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 29 Oct 2025 21:51:24 +0000
How about if 'is_trivially_relocatable_v' were to be taken out and replaced
with 'relocatability_v':

namespace std {
    template<typename T>
    struct relocatability : integral_constant<int, . . . >{};
}

The possible values being:

0 = cannot relocate
1 = can relocate by memcpy/memmove
2 = can relocate by implementation-specific built-in compiler algorithm
that never throws
3 = can relocate by static member function belonging to class (e.g.
T::_Relocate) that never throws
-3 = can relocate by static class member function belonging to class (e.g.
T::_Relocate) that might throw
4 = can relocate by nothrow-move and destroy
-4 = can relocate by move that might throw and destroy
5 = can relocate by nothrow-copy and destroy
-5 = can relocate by copy that might throw and destroy
6 = can relocate by nothrow-default-construction and nothrow-assignment and
destroy
-6 = can relocate by default-construction and assignment (either of which
might throw) and destroy

Received on 2025-10-29 21:51:29