Macro Subspace :: sus_class_trivially_relocatable

Mark a class as unconditionally trivially relocatable while also asserting that all of the types passed as arguments are also marked as such.

Typically all field types in the class should be passed to the macro as its arguments.

To additionally allow the class to be passed in registers, the class can be marked with the [[clang::trivial_abi]] attribute.

Use the TriviallyRelocatable concept to determine if a type is trivially relocatable, and to test with static_assert that types are matching what you are expecting. This allows containers to optimize their implementations when relocating the type in memory.

Macro Style
sus_class_trivially_relocatable asserts all param types are trivially relocatable
sus_class_trivially_relocatable_if_types is conditionally trivially relocatable if all param types are
sus_class_trivially_relocatable_if is conditionally trivially relocatable if the condition is true
sus_class_trivially_relocatable_unchecked is trivially relocatable without any condition or assertion

Example

struct S {
  Thing<i32> thing;
  i32 more;

  sus_class_trivially_relocatable(
      unsafe_fn,
      decltype(thing),
      decltype(more));
};