Trivially relocatable types (Moveable)
First important note: U++ Moveable is not to be confused with C++ standard library move semantics, but is the original name of U++ equivalent of trivially_relocatable type - type’s relocation operation has novisible side-effects other than a copy of the underlying bytes, as if by the library function std::memcpy
U++ flavor of this technique is based on marking trivially relocatable types, as defined by future C++ standard according to P1144 by inheriting from TriviallyRelocatable<T> or Moveable<T> base (older shorter synonym).
struct Foo : TriviallyRelocatable<Foo> {
.....
};
or
struct Foo : Moveable<Foo> {
.....
};
U++ require that elements of Upp::Vector, Upp::BiVector, Upp::Index, Upp::VectorMap and keys of Upp::VectorMap and Upp::ArrayMap are trivially relocatable or trivially copyable (that allows all POD types without any further warrants by programmer). Alternatively, type can be explicitly allowed to be part of these containers without being trivially relocatable using
template <>
inline constexpr bool Upp::is_upp_guest<std::string> = true;
U++ then uses normal move contructor and destructor to relocate element.
Obviously, in the future, when / if P1144 is accepted, Upp trivially relocatable types will also include the proposed mechanisms in C++ standard.
|