[libcxx-commits] [libcxx] [libc++] Add the __is_replaceable type trait (PR #132408)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 24 13:20:03 PDT 2025


================
@@ -120,6 +121,10 @@ class _LIBCPP_TEMPLATE_VIS vector {
       __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
       vector,
       void>;
+  using __replaceable _LIBCPP_NODEBUG =
+      __conditional_t<__is_replaceable<pointer>::value && __container_allocator_is_replaceable<__alloc_traits>::value,
+                      vector,
+                      void>;
----------------
mordante wrote:

I'm more concerned about
```
//--- MyHeader.h
#include <__vector/vector_bool.h> 

void f(std::vector<bool>);

//--- TU1.cpp
#include "MyHeader.h"

// uses std::vector<bool>

//--- TU2.cpp
#include <vector> 
#include "MyHeader.h"

// uses std::vector<bool>
```
Users shouldn't include `<__vector/vector_bool.h>` but one of our headers may just do that.

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


More information about the libcxx-commits mailing list