Issue 2873: Add noexcept to several shared_ptr related functions (original) (raw)
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.
2873. Add noexcept
to several shared_ptr
related functions
Section: 20.3.2.2 [util.smartptr.shared] Status: C++17 Submitter: United States Opened: 2017-02-03 Last modified: 2020-09-06
Priority: Not Prioritized
View all other issues in [util.smartptr.shared].
View all issues with C++17 status.
Discussion:
Addresses US 124
Several shared_ptr
related functions have wide contracts and cannot throw, so should be marked unconditionally noexcept
.
Proposed change:
Add noexcept
to:
template bool shared_ptr::owner_before(shared_ptr const& b) const noexcept;
template bool shared_ptr::owner_before(weak_ptr const& b) const noexcept;
template bool
weak_ptr::owner_before(shared_ptr const& b) const noexcept;template bool weak_ptr::owner_before(weak_ptr const& b) const noexcept;
bool owner_less::operator()(A,B) const noexcept; // all versions
[2017-02-20, Marshall adds wording]
[Kona 2017-02-27]
Accepted as Immediate to resolve NB comment.
Proposed resolution:
This wording is relative to N4640.
- Modify 20.3.2.2 [util.smartptr.shared] as indicated:
template bool owner_before(const shared_ptr& b) const noexcept;
template bool owner_before(const weak_ptr& b) const noexcept; - Modify 20.3.2.2.6 [util.smartptr.shared.obs] as indicated:
template bool owner_before(const shared_ptr& b) const noexcept;
template bool owner_before(const weak_ptr& b) const noexcept; - Modify 20.3.2.4 [util.smartptr.ownerless] as indicated:
template struct owner_less<shared_ptr> {
bool operator()(const shared_ptr&, const shared_ptr&) const noexcept;
bool operator()(const shared_ptr&, const weak_ptr&) const noexcept;
bool operator()(const weak_ptr&, const shared_ptr&) const noexcept;
};template struct owner_less<weak_ptr> {
bool operator()(const weak_ptr&, const weak_ptr&) const noexcept;
bool operator()(const shared_ptr&, const weak_ptr&) const noexcept;
bool operator()(const weak_ptr&, const shared_ptr&) const noexcept;
};template<> struct owner_less {
template<class T, class U>
bool operator()(const shared_ptr&, const shared_ptr&) const noexcept;
template<class T, class U>
bool operator()(const shared_ptr&, const weak_ptr&) const noexcept;
template<class T, class U>
bool operator()(const weak_ptr&, const shared_ptr&) const noexcept;
template<class T, class U>
bool operator()(const weak_ptr&, const weak_ptr&) const noexcept;
using is_transparent = unspecified;
};