[libcxx-commits] [libcxx] [libc++] P2747R2: `constexpr` placement new (library part) (PR #105768)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 27 14:26:27 PDT 2024


================
@@ -15,19 +15,30 @@
 
 int A_constructed = 0;
 
-struct A
-{
-    A() {++A_constructed;}
-    ~A() {--A_constructed;}
+struct A {
+  A() { ++A_constructed; }
+  ~A() { --A_constructed; }
 };
 
-int main(int, char**)
-{
-    char buf[sizeof(A)];
+TEST_CONSTEXPR_OPERATOR_NEW void test_direct_call() {
+  assert(::operator new(sizeof(int), &A_constructed) == &A_constructed);
----------------
ldionne wrote:

```suggestion
  assert(::operator new(sizeof(A), &A_constructed) == &A_constructed);
```

Isn't that less confusing? Any reason you used `sizeof(int)`?

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


More information about the libcxx-commits mailing list