Page MenuHomePhabricator

P1144 "Trivially relocatable" (2/3): explicit warrants for std library types
Needs ReviewPublic

Authored by Quuxplusone on Jun 20 2019, 12:36 PM.

Details

Reviewers
ldionne
Summary

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 patch has no ABI implications (or if it does, that's a bug, please tell me about it). This patch doesn't do any special optimizations (e.g. to std::vector::reserve); those will come in part 3/3.

TODO:

  • how should the new tests be guarded so that they don't fail on compilers lacking __has_extension(__is_trivially_relocatable)?
  • I made std::vector<bool>::__storage_pointer a public member; I don't know if this is acceptable.
  • The code for many containers would be shorter if we use [[maybe_trivially_relocatable]] instead of [[trivially_relocatable(all my members are trivially relocatable)]]. P1144 discusses, but doesn't propose, [[maybe_trivially_relocatable]]. D50119 does implement it.
  • explicit warrants for stack, queue, and priority_queue (which would not be needed if those types could follow the Rule of Zero; see D61139 for details)

Diff Detail

Repository
rCXX libc++