Title
shared_ptr::shared_ptr(Y*, D, […]) constructors should be constrained
Status
c++17
Section
[util.smartptr.shared.const]
Submitter
United States

Created on 2017-02-03.00:00:00 last changed 90 months ago

Messages

Date: 2017-03-03.22:08:49

Proposed resolution:

This wording is relative to N4640 as modified by the proposed resolution of LWG 2802.

  1. Modify [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 be MoveConstructible and cConstruction of d and a deleter of type D initialized with std::move(d) shall not throw exceptions. The expression d(p) shall be well formed, shall have well-defined behavior, and shall not throw exceptions. A shall be an allocator (17.5.3.5). When T is U[N], Y(*)[N] shall be convertible to T*; when T is U[], Y(*)[] shall be convertible to T*; otherwise, Y* shall be convertible to T*.

  2. 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: When T is an array type, this constructor shall not participate in overload resolution unless is_move_constructible_v<D> is true, the expression d(p) is well-formed, and either T is U[N] and Y(*)[N] is convertible to T*, or T is U[] and Y(*)[] is convertible to T*. When T is not an array type, this constructor shall not participate in overload resolution unless is_move_constructible_v<D> is true, the expression d(p) is well-formed, and Y* is convertible to T*.

Date: 2017-03-03.22:08:49

[ Kona 2017-02-27 ]

Accepted as Immediate to resolve NB comment.

Date: 2017-02-28.03:05:42

[ Kona 2017-02-27: Jonathan updates wording after LWG review ]

Date: 2017-02-15.00:00:00

[ 2017-02-23, Jonathan provides wording ]

This wording is relative to N4640.

  1. Modify [util.smartptr.shared.const] as indicated:

    1. If the proposed resolution of LWG 2802 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 be MoveConstructible and cConstruction of d and a deleter of type D initialized with std::move(d) shall not throw exceptions. The expression d(p) shall be well formed, shall have well-defined behavior, and shall not throw exceptions. A shall be an allocator (17.5.3.5). When T is U[N], Y(*)[N] shall be convertible to T*; when T is U[], Y(*)[] shall be convertible to T*; otherwise, Y* shall be convertible to T*.

    2. If the proposed resolution of LWG 2802 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 be CopyConstructible and such cConstruction of d and a copy of d shall not throw exceptions. The destructor of D shall not throw exceptions. The expression d(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 of A shall not throw exceptions. When T is U[N], Y(*)[N] shall be convertible to T*; when T is U[], Y(*)[] shall be convertible to T*; otherwise, Y* shall be convertible to T*.

  1. In either case, add a Remarks paragraph after p11:

    [Drafting note: If LWG 2802 is not accepted, replace is_move_constructible_v with is_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: When T is an array type, this constructor shall not participate in overload resolution unless is_move_constructible_v<D> is true, the expression d(p) is well-formed, and either T is U[N] and Y(*)[N] is convertible to T*, or Y(*)[] is convertible to T*. When T is not an array type, this constructor shall not participate in overload resolution unless is_move_constructible_v<D> is true, the expression d(p) is well-formed, and Y* is convertible to T*.

Date: 2017-02-03.21:14:26

[ 2017-02 pre-Kona ]

See US 125: LWG 2874.

Date: 2017-02-03.00:00:00

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.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2017-03-05 23:46:08adminsetstatus: immediate -> wp
2017-03-03 22:08:49adminsetmessages: + msg9057
2017-03-03 22:08:49adminsetstatus: new -> immediate
2017-02-28 03:05:42adminsetmessages: + msg9010
2017-02-23 21:46:30adminsetmessages: + msg8992
2017-02-23 21:46:30adminsetmessages: + msg8991
2017-02-03 21:14:26adminsetmessages: + msg8865
2017-02-03 00:00:00admincreate