This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.
2875.shared_ptr::shared_ptr(Y*, D, […])
constructors should be constrained
Section: 20.3.2.2.2 [util.smartptr.shared.const] Status: C++17 Submitter: United States Opened: 2017-02-03 Last modified: 2020-09-06
Priority: Not Prioritized
View other active issues in [util.smartptr.shared.const].
View all other issues in [util.smartptr.shared.const].
View all issues with C++17 status.
Discussion:
Addresses US 126
Paragraph 8: This constructor should not participate in overload resolution unless the Requires clause is satisfied. Note that this would therefore apply to some assignment operator and reset
overloads, via Effects: equivalent to some code wording.
Proposed change:
Add a Remarks: clause to constrain this constructor not to participate in overload resolution unless the Requires clause is satisfied.
[2017-02 pre-Kona]
[2017-02-23, Jonathan provides wording]
This wording is relative to N4640.
Modify 20.3.2.2.2 [util.smartptr.shared.const] as indicated:
If the proposed resolution of LWG 2802(i) has been accepted modify p8 as shown:
template<class Y, class D> shared_ptr(Y* p, D d); template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); template <class D> shared_ptr(nullptr_t p, D d); template <class D, class A> shared_ptr(nullptr_t p, D d, A a);-8- Requires:
D
shall beMoveConstructible
and c Construction ofd
and a deleter of typeD
initialized withstd::move(d)
shall not throw exceptions. The expressiond(p)
shall be well formed, shall have well-defined behavior, and shall not throw exceptions.A
shall be an allocator (17.5.3.5). WhenT
isU[N]
,Y(*)[N]
shall be convertible toT*
; whenT
isU[]
,Y(*)[]
shall be convertible toT*
; otherwise,Y*
shall be convertible toT*
.
If the proposed resolution of LWG 2802(i) has not been accepted modify p8 as shown:
template<class Y, class D> shared_ptr(Y* p, D d); template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); template <class D> shared_ptr(nullptr_t p, D d); template <class D, class A> shared_ptr(nullptr_t p, D d, A a);-8- Requires:
D
shall beCopyConstructible
and such c Construction ofd
and a copy ofd
shall not throw exceptions. The destructor ofD
shall not throw exceptions. The expressiond(p)
shall be well formed, shall have well defined behavior, and shall not throw exceptions.A
shall be an allocator (17.5.3.5). The copy constructor and destructor ofA
shall not throw exceptions. WhenT
isU[N]
,Y(*)[N]
shall be convertible toT*
; whenT
isU[]
,Y(*)[]
shall be convertible toT*
; otherwise,Y*
shall be convertible toT*
.
In either case, add a Remarks paragraph after p11:
[Drafting note: If LWG 2802(i) is not accepted, replace
is_move_constructible_v
withis_copy_constructible_v
.]
template<class Y, class D> shared_ptr(Y* p, D d); template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); template <class D> shared_ptr(nullptr_t p, D d); template <class D, class A> shared_ptr(nullptr_t p, D d, A a);-8- Requires: […]
[…] -11- Throws: […] -?- Remarks: WhenT
is an array type, this constructor shall not participate in overload resolution unlessis_move_constructible_v<D>
istrue
, the expressiond(p)
is well-formed, and eitherT
isU[N]
andY(*)[N]
is convertible toT*
, orY(*)[]
is convertible toT*
. WhenT
is not an array type, this constructor shall not participate in overload resolution unlessis_move_constructible_v<D>
istrue
, the expressiond(p)
is well-formed, andY*
is convertible toT*
.
[Kona 2017-02-27: Jonathan updates wording after LWG review]
[Kona 2017-02-27]
Accepted as Immediate to resolve NB comment.
Proposed resolution:
This wording is relative to N4640 as modified by the proposed resolution of LWG 2802(i).
Modify 20.3.2.2.2 [util.smartptr.shared.const] as indicated:
template<class Y, class D> shared_ptr(Y* p, D d); template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); template <class D> shared_ptr(nullptr_t p, D d); template <class D, class A> shared_ptr(nullptr_t p, D d, A a);-8- Requires:
D
shall beMoveConstructible
and c Construction ofd
and a deleter of typeD
initialized withstd::move(d)
shall not throw exceptions. The expressiond(p)
shall be well formed, shall have well-defined behavior, and shall not throw exceptions.A
shall be an allocator (17.5.3.5). WhenT
isU[N]
,Y(*)[N]
shall be convertible toT*
; whenT
isU[]
,Y(*)[]
shall be convertible toT*
; otherwise,Y*
shall be convertible toT*
.
Add a Remarks paragraph after p11:
template<class Y, class D> shared_ptr(Y* p, D d); template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); template <class D> shared_ptr(nullptr_t p, D d); template <class D, class A> shared_ptr(nullptr_t p, D d, A a);-8- Requires: […]
[…] -11- Throws: […] -?- Remarks: WhenT
is an array type, this constructor shall not participate in overload resolution unlessis_move_constructible_v<D>
istrue
, the expressiond(p)
is well-formed, and eitherT
isU[N]
andY(*)[N]
is convertible toT*
, orT
isU[]
andY(*)[]
is convertible toT*
. WhenT
is not an array type, this constructor shall not participate in overload resolution unlessis_move_constructible_v<D>
istrue
, the expressiond(p)
is well-formed, andY*
is convertible toT*
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4