[libcxx-commits] [PATCH] D110994: [libc++] Make test_allocator constexpr-friendly for constexpr string/vector
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 12 07:48:48 PDT 2021
ldionne added a comment.
There is some overlap with D68365 <https://reviews.llvm.org/D68365> (let's move forward with this patch and I can rebase onto it). You might want to take a look at what I did in D68365 <https://reviews.llvm.org/D68365> in case that gives you ideas. I also think we'll want to pick parts of D68365 <https://reviews.llvm.org/D68365> out (like the `shared_ptr` emulation).
================
Comment at: libcxx/test/support/test_allocator.h:256-263
#if TEST_STD_VER < 11
- void construct(pointer p, const T& val)
- {::new(static_cast<void*>(p)) T(val);}
+ void construct(pointer p, const T& val) { ::new (static_cast<void*>(p)) T(val); }
#else
- template <class U> void construct(pointer p, U&& val)
- {::new(static_cast<void*>(p)) T(std::forward<U>(val));}
+ template <class U>
+ void construct(pointer p, U&& val) {
+ ::new (static_cast<void*>(p)) T(std::forward<U>(val));
+ }
----------------
Based on what I did in D68365, I think the correct definition of this would be:
```
#if TEST_STD_VER < 11
void construct(pointer p, const T& val) {
::new(static_cast<void*>(p)) T(val);
}
#elif TEST_STD_VER < 20
template <class U>
void construct(pointer p, U&& val) {
::new(static_cast<void*>(p)) T(std::forward<U>(val));
}
#else
template <class U>
constexpr void construct(pointer p, U&& val) {
std::construct_at(p, std::forward<U>(val));
}
#endif
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110994/new/
https://reviews.llvm.org/D110994
More information about the libcxx-commits
mailing list