Title
Missing noexcept in shared_ptr::shared_ptr(nullptr_t)
Status
c++17
Section
[util.smartptr.shared]
Submitter
Cassio Neri

Created on 2014-02-13.00:00:00 last changed 90 months ago

Messages

Date: 2014-03-26.21:11:34

Proposed resolution:

This wording is relative to N3936.

  1. Change class template shared_ptr synopsis, [util.smartptr.shared], as indicated:

    constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { }
    
Date: 2014-03-26.00:00:00

[ 2014-03-26 Library reflector vote ]

The issue has been identified as Tentatively Ready based on six votes in favour.

Date: 2014-02-13.00:00:00

The declaration and definition of shared_ptr::shared_ptr(nullptr_t), given in [util.smartptr.shared], is

constexpr shared_ptr(nullptr_t) : shared_ptr() { }

The intention seems clear: this constructor should have the same semantics of the default constructor. However, contrarily to the default constructor, this one is not noexcept. In contrast, unique_ptr::unique_ptr(nullptr_t) is noexcept, as per [unique.ptr.single]:

constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }

Both libstdc++ and libc++ have added noexcept to shared_ptr::shared_ptr(nullptr_t). Microsoft's STL has not.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2014-11-08 19:44:42adminsetstatus: voting -> wp
2014-11-04 10:26:50adminsetstatus: ready -> voting
2014-03-26 21:11:34adminsetmessages: + msg6924
2014-03-26 21:11:34adminsetstatus: new -> ready
2014-03-23 20:27:06adminsetmessages: + msg6905
2014-02-13 00:00:00admincreate