Skip to content

Commit

Permalink
375 - Did you know C++26 added support constexpr placement new?
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-jusiak committed Sep 10, 2024
1 parent bc5c674 commit f79781c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

> C++26
* [Did you know C++26 added support constexpr placement new?](https://github.com/tip-of-the-week/cpp/blob/master/tips/375.md)
* [Did you know that C++26 added `= delete("should have a reason")`?](https://github.com/tip-of-the-week/cpp/blob/master/tips/371.md)
* [Did you know that C++26 added `span.at`?](https://github.com/tip-of-the-week/cpp/blob/master/tips/370.md)
* [Did you know about C++26 simd proposal (1/N)?](https://github.com/tip-of-the-week/cpp/blob/master/tips/367.md)
Expand Down
25 changes: 25 additions & 0 deletions tips/375.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<details open><summary>Info</summary><p>

* **Did you know C++26 added support constexpr placement new?

* https://wg21.link/P2747

</p></details><details open><summary>Example</summary><p>

```cpp
static_assert([] {
std::array<int, 1024> storage{};
auto ptr = new (storage.data()) int{42};
return 42 == *ptr;
}());

static_assert([] {
std::array<int, 1024> storage{};
auto ptr = std::construct_at<int>(storage.data(), 42);
return 42 == *ptr;
}());
```
> https://godbolt.org/z/61Kcjz1s6
</p></details>

0 comments on commit f79781c

Please sign in to comment.