Questions tagged [c++23]

C++23 is the target for the version of C++ after C++20. This tag should be used (along with the C++ tag) for questions about C++ features on track for C++23.

C++23 is, most probably, the name of the C++ standard that will come after C++20. It builds upon the previous Standard, improving the core language and Standard Library, and adding a few new language features.

Find here the latest Working Draft of the Standard. See more information at the Standard C++ Foundation webpage.

Please tag questions about C++23 with , as well as with .

192 questions
56
votes
1 answer

Why is std::aligned_storage to be deprecated in C++23 and what to use instead?

I just saw that C++23 plans to deprecate both std::aligned_storage and std::aligned_storage_t as well as std::aligned_union and std::aligned_union_t. Placement new'd objects in aligned storage are not particularly constexpr friendly as far as I…
bitmask
  • 32,434
  • 14
  • 99
  • 159
32
votes
2 answers

What are the implications of constexpr floating-point math?

Since C++11, we are able to do floating point math at compile time. C++23 and C++26 added constexpr to some functions, but not to all. constexpr floating point math is weird in general, because the results aren't perfectly accurate. However,…
Jan Schultke
  • 17,446
  • 6
  • 47
  • 96
32
votes
1 answer

The validity of lambda expression with omitted parameter list in C++23

According to cppreference, both gcc and clang have completed the implementation of P1102R2 ("Down with ()!") recently, which means we can define lambda expressions more concisely in C++23. But I found that they are inconsistent with a certain…
康桓瑋
  • 33,481
  • 5
  • 40
  • 90
28
votes
1 answer

What is std::expected in C++?

In one of the most respected stackoverflow answer I found an example of std::expected template class usages: What are coroutines in C++20? At the same time I cannot find any mentioning of this class on cppreference.com. Could you please explain what…
Fedor
  • 17,146
  • 13
  • 40
  • 131
24
votes
2 answers

Are floatN_t in stdfloat guarenteed to be IEEE compliant?

Unlike fundamental types – float, double and long double – are the new floatN_t types in introduced in C++23 going to be always IEEE standard binary floating point types? The cppreference page for fixed width floating-point does mention…
Sourav Kannantha B
  • 2,860
  • 1
  • 11
  • 35
22
votes
2 answers

Why does std::views::split() compile but not split with an unnamed string literal as a pattern?

When std::views::split() gets an unnamed string literal as a pattern, it will not split the string but works just fine with an unnamed character literal. #include #include #include #include #include…
khaos
  • 632
  • 3
  • 11
21
votes
1 answer

reflection TS - in C++23?

Reflection TS - C++ feature described here: https://en.cppreference.com/w/cpp/keyword/reflexpr I am looking for any information about this feature. I have this table describing compiler support: https://en.cppreference.com/w/cpp/compiler_support but…
montjet
  • 525
  • 1
  • 4
  • 13
18
votes
1 answer

Functional equivalency in template constraints vs member function constraints

The latest standard draft N4910 has this example in [temp.over.link] regarding functional equivalence: template concept C = true; template struct A { void f() requires C<42>; // #1 void f() requires true; // OK, different…
user17732522
  • 53,019
  • 2
  • 56
  • 105
18
votes
1 answer

What is if consteval needed for?

C++23 is going to introduce if consteval. Where is this going to be used and how does it differ from constexpr if?
Claas Bontus
  • 1,628
  • 1
  • 15
  • 29
16
votes
1 answer

Why is there still no range-enabled reduction algorithm in std?

The only options available are std::ranges::for_each and simple range-based for loop. No counterparts for std::accumulate, std::reduce or std::inner_product. std::ranges::reduce would be enough, if it were present; inner product can be achieved…
Red.Wave
  • 2,790
  • 11
  • 17
16
votes
3 answers

Why does the use of `std::aligned_storage` allegedly cause UB due to it failing to "provide storage"?

Inspired by: Why is std::aligned_storage to be deprecated in C++23 and what to use instead? The linked proposal P1413R3 (that deprecates std::aligned_storage) says that: Using aligned_* invokes undefined behavior (The types cannot provide…
HolyBlackCat
  • 78,603
  • 9
  • 131
  • 207
16
votes
1 answer

Understanding std::inout_ptr and std::out_ptr in C++23

I've being reading the list of library changes proposed for C++23 and I'm quite curious about the std::out_ptr and std::inout_ptr (their _t siblings). As far as I understand they are some kind of wrapper for smart pointers to be compatible with raw…
cbuchart
  • 10,847
  • 9
  • 53
  • 93
15
votes
3 answers

Why allocate_at_least() in C++23?

According to cppref: std::allocator::allocate_at_least Allocates count * sizeof(T) bytes of uninitialized storage, where count is an unspecified integer value not less than n, by calling ::operator new (an additional std::align_val_t argument…
xmllmx
  • 39,765
  • 26
  • 162
  • 323
14
votes
1 answer

Why does C++23 string::resize_and_overwrite invoke operation as an rvalue?

In order to improve the performance of writing data into std::string, C++23 specially introduced resize_and_overwrite() for std::string. In [string.capacity], the standard describes it as follows: template constexpr void…
康桓瑋
  • 33,481
  • 5
  • 40
  • 90
13
votes
2 answers

What happens when an assumption, i.e. [[assume]] contains UB?

In C++23, the [[assume(expression)]] attribute makes it so that if expression is false, the behavior is undefined. For example: int div(int x, int y) { [[assume(y == 1)]]; return x / y; } This compiles to the same code as if y was always…
Jan Schultke
  • 17,446
  • 6
  • 47
  • 96
1
2 3
12 13