[libcxx-commits] [libcxx] [libc++] Implement `std::inplace_vector<T, N>` (PR #105981)

Mital Ashok via libcxx-commits libcxx-commits at lists.llvm.org
Sun Aug 25 05:01:00 PDT 2024


MitalAshok wrote:

To-do list:
 - Finish up tests
   - I copied over the vector tests and removed asan/allocator tests. Finish rewriting them in terms of `inplace_vector`.
   - Add new tests for `inplace_vector` specific members
 - Investigate standards conformance
   - Currently there is an extension where this class is usable in a constant expression if `is_trivially_default_constructible_v<T> && is_trivially_destructible_v<T>`. The standard says this is not correct (https://eel.is/c++draft/inplace.vector#overview-4), but it can easily be removed. There is also the issue of static member functions and `data()` being usable in a constant expression when `!is_trivial_v<T> && N!=0`. I have emailed lwg about this.
   - The standard signature of:
      ```c++
      friend synth-three-way-result<T>
        operator<=>(const inplace_vector& x, const inplace_vector& y)
      ```
      is unimplementable as written. It would require `x[0] < y[0]` to be well formed to instantiate the class, because `synth-three-way-result` requires this (https://eel.is/c++draft/expos.only.entity). I've made it a placeholder type and added a constraint too so `std::inplace_vector<T, 10>{} < std::inplace_vector<T, 10>{}` is not a hard error when T isn't comparable.
    - What are the properties of `std::inplace_vector<T, 0>`? The standard requires it to be trivially copy/move constructible/assignable. This implementation is only swappable if `T` is, and stuff like `try_push_back(t)` will only work if `t` is copyable.
 - Format the header file

https://github.com/llvm/llvm-project/pull/105981


More information about the libcxx-commits mailing list