Closed wg21bot closed 1 year ago
Proposed resolution is P2679 https://github.com/cplusplus/papers/issues/1345
TODO: Bryce Add polls and notes
POLL: We want to reject the proposed resolution of GB-087.
Strongly Favor | Weakly Favor | Neutral | Weakly Against | Strongly Against |
---|---|---|---|---|
11 | 6 | 3 | 0 | 0 |
Attendance: 20 + 3
# of Authors: 1
Author Position: SF
Outcome: Strong consensus
Poll 1.12: Reject C++23 National Body comment GB-087 start_lifetime_as Is Broken And Inconsistent For Arrays as per [P2679R1] Fixing start_lifetime_as For Arrays .
Strongly Favor | Weakly Favor | Neutral | Weakly Against | Strongly Against |
---|---|---|---|---|
14 | 3 | 1 | 1 | 0 |
Outcome: Consensus in favor.
Rejected. There was no consensus for a change.
The API of std::start_lifetime_as is broken and inconsistent for arrays.
First, is inconsistent with other APIs in the standard library that create objects and accept both array and non-array types, such as std::make_shared and std::make_unique. These have a version for non-array types, a version for array types of known bound, and a version for array types of unknown bound, respectively, all with the same name.
Further, the current naming is also inconsistent with itself in multiple ways: the overloads that work for arrays of unknown bound have the suffix _array in the name, but the overloads that work for arrays of known bound do not. This does not make any sense and is highly confusing for users.
In the same way that the naming is inconsistent with existing standard APIs and also with itself, the template parameters are also inconsistent. For std::start_lifetime_as, when used with an array type U[N] of known bound, the template argument that the user needs to provide is the type U[N] of the object being created (for example,
std::start_lifetime_as<int[16]>
), while for std::start_lifetime_as_array, the template argument is not the type U[] of the object being created, but the type of its elements U.Finally, the overloads for arrays of unknown bound (the ones with the suffix _array) return a pointer to the first element of the array, while the overloads without the suffix _array, when used with an array type of known bound, return a pointer to the array itself. In other words, a call to
std::start_lifetime_as_array<int>(p, 16)
will return an int, but at the same time a call tostd::start_lifetime_as<int[16]>(p)
will return an `int()[16]`, which makes creating and using arrays with this facility very awkward and unintuitive.Adopt the changes proposed in P2679R0.