[libcxx-commits] [libcxx] [libcxx][string] Test: default constructed allocators can be unequal (PR #195839)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 6 23:10:18 PDT 2026


frederick-vs-ja wrote:

Can we also introduce such allocator types in this PR?

It's interesting that compilers consistently accept the following example ([Godbolt link](https://godbolt.org/z/ej4dedxKo)).
```C++
struct S {
  constexpr S(unsigned int line_no = __builtin_LINE()) : payload_(line_no) {}
  unsigned int payload_;
};

static_assert(S{}.payload_ //
                  !=       //
                  S{}.payload_,
              "");
```

Perhaps we can use such mechanism in constant evaluation since C++20.

For runtime behavior, IMO we can introduce something like `polymorphic_allocator` and `(get|set)_default_resource`.

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


More information about the libcxx-commits mailing list