Created on 2025-11-05.00:00:00 last changed 1 week ago
Proposed resolution:
This wording is relative to N5014.
Modify [util.smartptr.shared.create], as indicated:
template<class T> constexpr shared_ptr<T> make_shared(size_t N); // T is U[] template<class T, class A> constexpr shared_ptr<T> allocate_shared(const A& a, size_t N); // T is U[]-12- Constraints: `T` is
of the form `U[]`an array of unknown bound.-13- Returns: A `shared_ptr` to an
object of type `U[N]`array of `N` elements of typeremove_extent_t<T>with a default initial value, where `U` is.remove_extent_t<T>-14- [Example 2: ...]
template<class T> constexpr shared_ptr<T> make_shared(); // T is U[N] template<class T, class A> constexpr shared_ptr<T> allocate_shared(const A& a); // T is U[N]-15- Constraints: `T` is
of the form `U[N]`an array of known bound.-16- Returns: A `shared_ptr` to an object of type `T` with a default initial value.
-17- [Example 3: ...]
template<class T> constexpr shared_ptr<T> make_shared(size_t N, const remove_extent_t<T>& u); // T is U[] template<class T, class A> constexpr shared_ptr<T> allocate_shared(const A& a, size_t N, const remove_extent_t<T>& u); // T is U[]-18- Constraints: `T` is
of the form `U[]`an array of unknown bound.-19- Returns: A `shared_ptr` to an
object of type `U[N]`array of `N` elements of typeremove_extent_t<T>where`U` iseach array element has an initial value of `u`.remove_extent_t<T>and-20- [Example 4: ...]
template<class T> constexpr shared_ptr<T> make_shared(const remove_extent_t<T>& u); // T is U[N] template<class T, class A> constexpr shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& u); // T is U[N]-21- Constraints: `T` is
of the form `U[N]`an array of known bound.-22- Returns: A `shared_ptr` to an object of type `T`, where each array element of type
remove_extent_t<T>has an initial value of `u`.-23- [Example 5: ...]
template<class T> constexpr shared_ptr<T> make_shared_for_overwrite(); // T is U[N] template<class T, class A> constexpr shared_ptr<T> allocate_shared_for_overwrite(const A& a); // T is U[N]-24- Constraints: `T` is not an array of unknown bound.
-25- Returns: A `shared_ptr` to an object of type `T`.
-26- [Example 6: ...]
template<class T> constexpr shared_ptr<T> make_shared_for_overwrite(size_t N); // T is U[] template<class T, class A> constexpr shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N); // T is U[]-27- Constraints: `T` is an array of unknown bound.
-28- Returns: A `shared_ptr` to an
object of type `U[N]`array of `N` elements of typeremove_extent_t<T>, where `U` is.remove_extent_t<T>-29- [Example 7: ...]
[ Kona 2025-11-08; Status changed: Immediate → WP. ]
[ Kona 2025-11-06; approved by LWG. Status changed: New → Immediate. ]
The overloads of `make_shared` and `allocate_shared` for creating
shared_ptr<T[]> refer to an object a type `U[N]`
where `N` is a function parameter not a constant expression.
Since `N` is allowed to be zero, this also allows `U[0]` which is
an invalid type and so totally ill-formed.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-11-11 10:48:55 | admin | set | messages: + msg15704 |
| 2025-11-11 10:48:55 | admin | set | status: immediate -> wp |
| 2025-11-06 19:31:14 | admin | set | messages: + msg15567 |
| 2025-11-06 19:31:14 | admin | set | status: new -> immediate |
| 2025-11-06 02:44:50 | admin | set | messages: + msg15544 |
| 2025-11-05 00:00:00 | admin | create | |