Part 0/3 is D50119: it adds __has_extension(__is_trivially_relocatable) to the compiler.
Part 1/3 is D61761: it implements the library traits and algorithms mandated by P1144.
Part 2/3 is D63620: it implements Quality-of-Implementation features to warrant certain std library types as "trivially relocatable."
Part 3/3 is D67524: it implements Quality-of-Implementation features to optimize certain std library functions for better performance on types that have been warranted "trivially relocatable."
This is the compiler half of C++ proposal 1144 "Object relocation in terms of move plus destroy," as seen on https://godbolt.org/g/zUUAVW and https://quuxplusone.github.io/blog/2018/07/18/announcing-trivially-relocatable/ .
There are two parts to this compiler support:
- the type trait __is_trivially_relocatable(T), which is similar in spirit to __is_trivially_destructible(T), in that it lets the programmer access information that the compiler itself already knows; and
- the warranting attribute [[clang::trivially_relocatable]], which is similar in spirit to [[clang::trivial_abi]], in that it lets the programmer communicate back to the compiler that a certain user-defined type should be assumed to have this property even though it would not naturally have the property all else being equal.
As proposed in P1144R3, [[clang::trivially_relocatable(some-bool-expr)]] can be used to make a type conditionally trivially relocatable. I used this version of the attribute very heavily in my libc++ patch D63620.
Furthermore, I've implemented @rjmccall's idea for an attribute [[clang::maybe_trivially_relocatable]] that says "My member functions don't interfere with my own trivial relocatability, but my data members' types might." Personally I have not used this version of the attribute, but I am certainly biased. See my C++Now 2019 session ( https://www.youtube.com/watch?v=SGdfPextuAU&t=40m ) for details on the different approaches to conditionally trivial relocatability.
The official home of this branch thus far has been https://github.com/Quuxplusone/clang/tree/trivially-relocatable , but I figure that a Clang review would be a good way to get some more eyeballs on it, plus, if we can get it into Clang trunk then I wouldn't have to keep rebasing it.