This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.
make_shared should not refer to a type U[N] for runtime NSection: 20.3.2.2.7 [util.smartptr.shared.create] Status: WP Submitter: Jonathan Wakely Opened: 2025-11-05 Last modified: 2025-11-11
Priority: Not Prioritized
View all other issues in [util.smartptr.shared.create].
View all issues with WP status.
Discussion:
Addresses US 76-139
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.
[Kona 2025-11-06; approved by LWG. Status changed: New → Immediate.]
[Kona 2025-11-08; Status changed: Immediate → WP.]
Proposed resolution:
This wording is relative to N5014.
Modify 20.3.2.2.7 [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:
Tisof the forman array of unknown bound.U[]-13- Returns: A
shared_ptrto anobject of typearray ofU[N]Nelements of typeremove_extent_t<T>with a default initial value, where.Uisremove_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:
Tisof the forman array of known bound.U[N]-16- Returns: A
shared_ptrto an object of typeTwith 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:
Tisof the forman array of unknown bound.U[]-19- Returns: A
shared_ptrto anobject of typearray ofU[N]Nelements of typeremove_extent_t<T>whereeach array element has an initial value ofUisremove_extent_t<T>andu.-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:
Tisof the forman array of known bound.U[N]-22- Returns: A
shared_ptrto an object of typeT, where each array element of typeremove_extent_t<T>has an initial value ofu.-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:
Tis not an array of unknown bound.-25- Returns: A
shared_ptrto an object of typeT.-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:
Tis an array of unknown bound.-28- Returns: A
shared_ptrto anobject of typearray ofU[N]Nelements of typeremove_extent_t<T>, where.Uisremove_extent_t<T>-29- [Example 7: ...]