[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 13 13:06:54 PDT 2018


Quuxplusone created this revision.
Quuxplusone added reviewers: EricWF, mclow.lists, erik.pilkington, vsapsai.
Herald added subscribers: cfe-commits, ldionne, christof.

Inspired by Volodymyr's work on https://reviews.llvm.org/D48753, I've taken it upon myself to refactor the static member functions `std::allocator_traits<A>::__construct_forward`, `__construct_backward`, and `__construct_range_forward` into non-member functions. I think this is reasonable just in terms of code-cleanliness — they don't *have* to be member functions for any reason I can think of — and then it also permits a suitably sadomasochistic programmer to define his own specialization of `std::allocator_traits` without causing compiler errors in `<vector>`.

I have added a test case in `test/libcxx/` for the sadomasochistic case, which I describe as "arguably ill-formed." I would be very very happy to see WG21 agree that specializing traits classes (pointer_traits, allocator_traits, iterator_traits) *is* ill-formed; I believe there's some disagreement on the subject at the moment.  In the meantime, I think this would be a nice patch just on code-cleanliness grounds.

This patch is also groundwork for the "trivially relocatable" fork that I'm building on my GitHub <https://github.com/Quuxplusone/clang/tree/trivially-relocatable>; we'd need an architecture something like this in order to easily drop in support for trivial relocatability.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49317

Files:
  include/memory
  include/vector
  test/libcxx/containers/sequences/vector/specialized_allocator_traits.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49317.155464.patch
Type: text/x-patch
Size: 12006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180713/ae61ca58/attachment.bin>


More information about the cfe-commits mailing list