[PATCH] D48753: [libcxx] Use custom allocator's `construct` in C++03 when available.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 4 16:16:45 PDT 2018


vsapsai added inline comments.


================
Comment at: libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp:60
+
+  void construct(pointer p, const value_type& val)
+  {
----------------
Quuxplusone wrote:
> Per my comments on D48342, I think it would be fun to add a test allocator like
> ```
> struct cpp03_fun_allocator : bare_allocator<T> {
>     ...
>     void construct(pointer p, const value_type& val) {
>         construct(p, val, std::is_class<T>{});
>     }
>     void construct(pointer p, const value_type& val, std::true_type) {
>         ::new(p) value_type(val);
>     }
>     void construct(pointer p, const value_type& val, std::false_type) {
>         ::new(p) value_type(val);
>     }
> ```
> and just see whether it passes the test suite. If it does, might as well add that test. But if it doesn't, *I'm* not going to force anyone to fix it. Allocators in C++03 seems like masochism to me. :)
I've tweaked the test a little bit: added `construct_called = true;` in 2 places, used `std::is_class<T>::value`. That shouldn't change your intention. Tried and it works in C++17 but not in C++03.

Given that it didn't work earlier, not planning to fix it now.


https://reviews.llvm.org/D48753





More information about the cfe-commits mailing list