diff --git a/libcxx/include/memory b/libcxx/include/memory index 8ef4588020f7..bd911a84bad8 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -433,8 +433,8 @@ public: long use_count() const noexcept; bool unique() const noexcept; explicit operator bool() const noexcept; - template bool owner_before(shared_ptr const& b) const; - template bool owner_before(weak_ptr const& b) const; + template bool owner_before(shared_ptr const& b) const noexcept; + template bool owner_before(weak_ptr const& b) const noexcept; }; // shared_ptr comparisons: @@ -531,8 +531,8 @@ public: long use_count() const noexcept; bool expired() const noexcept; shared_ptr lock() const noexcept; - template bool owner_before(shared_ptr const& b) const; - template bool owner_before(weak_ptr const& b) const; + template bool owner_before(shared_ptr const& b) const noexcept; + template bool owner_before(weak_ptr const& b) const noexcept; }; // weak_ptr specialized algorithms: @@ -546,9 +546,9 @@ struct owner_less> : binary_function, shared_ptr, bool> { typedef bool result_type; - bool operator()(shared_ptr const&, shared_ptr const&) const; - bool operator()(shared_ptr const&, weak_ptr const&) const; - bool operator()(weak_ptr const&, shared_ptr const&) const; + bool operator()(shared_ptr const&, shared_ptr const&) const noexcept; + bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; + bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; }; template @@ -556,9 +556,24 @@ struct owner_less> : binary_function, weak_ptr, bool> { typedef bool result_type; - bool operator()(weak_ptr const&, weak_ptr const&) const; - bool operator()(shared_ptr const&, weak_ptr const&) const; - bool operator()(weak_ptr const&, shared_ptr const&) const; + bool operator()(weak_ptr const&, weak_ptr const&) const noexcept; + bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; + bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; +}; + +template <> // Added in C++14 +struct owner_less +{ + template + bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept; + template + bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept; + template + bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept; + template + bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept; + + typedef void is_transparent; }; template @@ -3807,11 +3822,11 @@ public: _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;} template _LIBCPP_INLINE_VISIBILITY - bool owner_before(shared_ptr<_Up> const& __p) const + bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT {return __cntrl_ < __p.__cntrl_;} template _LIBCPP_INLINE_VISIBILITY - bool owner_before(weak_ptr<_Up> const& __p) const + bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT {return __cntrl_ < __p.__cntrl_;} _LIBCPP_INLINE_VISIBILITY bool @@ -4907,11 +4922,11 @@ public: shared_ptr<_Tp> lock() const _NOEXCEPT; template _LIBCPP_INLINE_VISIBILITY - bool owner_before(const shared_ptr<_Up>& __r) const + bool owner_before(const shared_ptr<_Up>& __r) const _NOEXCEPT {return __cntrl_ < __r.__cntrl_;} template _LIBCPP_INLINE_VISIBILITY - bool owner_before(const weak_ptr<_Up>& __r) const + bool owner_before(const weak_ptr<_Up>& __r) const _NOEXCEPT {return __cntrl_ < __r.__cntrl_;} template friend class _LIBCPP_TEMPLATE_VIS weak_ptr; @@ -5120,13 +5135,13 @@ struct _LIBCPP_TEMPLATE_VIS owner_less > { typedef bool result_type; _LIBCPP_INLINE_VISIBILITY - bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const + bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} _LIBCPP_INLINE_VISIBILITY - bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const + bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} _LIBCPP_INLINE_VISIBILITY - bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const + bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} }; @@ -5136,13 +5151,13 @@ struct _LIBCPP_TEMPLATE_VIS owner_less > { typedef bool result_type; _LIBCPP_INLINE_VISIBILITY - bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const + bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} _LIBCPP_INLINE_VISIBILITY - bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const + bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} _LIBCPP_INLINE_VISIBILITY - bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const + bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} }; @@ -5152,19 +5167,19 @@ struct _LIBCPP_TEMPLATE_VIS owner_less { template _LIBCPP_INLINE_VISIBILITY - bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const + bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} template _LIBCPP_INLINE_VISIBILITY - bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const + bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} template _LIBCPP_INLINE_VISIBILITY - bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const + bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} template _LIBCPP_INLINE_VISIBILITY - bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const + bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} typedef void is_transparent; }; diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp index 3acd2f8c6f2d..9f6f1bc75c71 100644 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp @@ -11,10 +11,11 @@ // shared_ptr -// template bool owner_before(shared_ptr const& b) const; +// template bool owner_before(shared_ptr const& b) const noexcept; #include #include +#include "test_macros.h" int main() { @@ -25,4 +26,5 @@ int main() assert(!p2.owner_before(p1)); assert(p1.owner_before(p3) || p3.owner_before(p1)); assert(p3.owner_before(p1) == p3.owner_before(p2)); + ASSERT_NOEXCEPT(p1.owner_before(p2)); } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp index 33447ba7da00..560293bbedb7 100644 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp @@ -11,10 +11,11 @@ // shared_ptr -// template bool owner_before(weak_ptr const& b) const; +// template bool owner_before(weak_ptr const& b) const noexcept; #include #include +#include "test_macros.h" int main() { @@ -28,4 +29,5 @@ int main() assert(!p2.owner_before(w1)); assert(p1.owner_before(w3) || p3.owner_before(w1)); assert(p3.owner_before(w1) == p3.owner_before(w2)); + ASSERT_NOEXCEPT(p1.owner_before(w2)); } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp index 142eba2d9647..7ab60da77c7d 100644 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp @@ -16,9 +16,9 @@ // : binary_function, shared_ptr, bool> // { // typedef bool result_type; -// bool operator()(shared_ptr const&, shared_ptr const&) const; -// bool operator()(shared_ptr const&, weak_ptr const&) const; -// bool operator()(weak_ptr const&, shared_ptr const&) const; +// bool operator()(shared_ptr const&, shared_ptr const&) const noexcept; +// bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; +// bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; // }; // // template @@ -26,22 +26,22 @@ // : binary_function, weak_ptr, bool> // { // typedef bool result_type; -// bool operator()(weak_ptr const&, weak_ptr const&) const; -// bool operator()(shared_ptr const&, weak_ptr const&) const; -// bool operator()(weak_ptr const&, shared_ptr const&) const; +// bool operator()(weak_ptr const&, weak_ptr const&) const noexcept; +// bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; +// bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; // }; // // Added in C++17 // template<> struct owner_less // { // template -// bool operator()(shared_ptr const&, shared_ptr const&) const; +// bool operator()(shared_ptr const&, shared_ptr const&) const noexcept; // template -// bool operator()(shared_ptr const&, weak_ptr const&) const; +// bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; // template -// bool operator()(weak_ptr const&, shared_ptr const&) const; +// bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; // template -// bool operator()(weak_ptr const&, weak_ptr const&) const; +// bool operator()(weak_ptr const&, weak_ptr const&) const noexcept; // // typedef unspecified is_transparent; // }; @@ -69,16 +69,19 @@ int main() static_assert((std::is_same, CS::first_argument_type>::value), "" ); static_assert((std::is_same, CS::second_argument_type>::value), "" ); static_assert((std::is_same::value), "" ); - + assert(!cs(p1, p2)); assert(!cs(p2, p1)); assert(cs(p1 ,p3) || cs(p3, p1)); assert(cs(p3, p1) == cs(p3, p2)); + ASSERT_NOEXCEPT(cs(p1, p1)); assert(!cs(p1, w2)); assert(!cs(p2, w1)); assert(cs(p1, w3) || cs(p3, w1)); assert(cs(p3, w1) == cs(p3, w2)); + ASSERT_NOEXCEPT(cs(p1, w1)); + ASSERT_NOEXCEPT(cs(w1, p1)); } { typedef std::owner_less > CS; @@ -92,11 +95,14 @@ int main() assert(!cs(w2, w1)); assert(cs(w1, w3) || cs(w3, w1)); assert(cs(w3, w1) == cs(w3, w2)); + ASSERT_NOEXCEPT(cs(w1, w1)); assert(!cs(w1, p2)); assert(!cs(w2, p1)); assert(cs(w1, p3) || cs(w3, p1)); assert(cs(w3, p1) == cs(w3, p2)); + ASSERT_NOEXCEPT(cs(w1, p1)); + ASSERT_NOEXCEPT(cs(p1, w1)); } #if TEST_STD_VER > 14 { @@ -111,6 +117,10 @@ int main() cmp(sp1, sp3); cmp(wp1, sp1); cmp(wp1, wp1); + ASSERT_NOEXCEPT(cmp(sp1, sp1)); + ASSERT_NOEXCEPT(cmp(sp1, wp1)); + ASSERT_NOEXCEPT(cmp(wp1, sp1)); + ASSERT_NOEXCEPT(cmp(wp1, wp1)); } { // test heterogeneous lookups diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp index 4aa49cfe8a24..458f8a11ed12 100644 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp @@ -11,10 +11,11 @@ // weak_ptr -// template bool owner_before(const shared_ptr& b); +// template bool owner_before(const shared_ptr& b) const noexcept; #include #include +#include "test_macros.h" int main() { @@ -28,4 +29,6 @@ int main() assert(!w2.owner_before(p1)); assert(w1.owner_before(p3) || w3.owner_before(p1)); assert(w3.owner_before(p1) == w3.owner_before(p2)); +// change to 'ASSERT_NOEXCEPT' when LWG2942 is adopted + LIBCPP_ASSERT_NOEXCEPT(w1.owner_before(p2)); } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp index 9fe2b6e39035..5cd171a53021 100644 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp @@ -11,10 +11,11 @@ // weak_ptr -// template bool owner_before(const weak_ptr& b); +// template bool owner_before(const weak_ptr& b) const noexcept; #include #include +#include "test_macros.h" int main() { @@ -28,4 +29,6 @@ int main() assert(!w2.owner_before(w1)); assert(w1.owner_before(w3) || w3.owner_before(w1)); assert(w3.owner_before(w1) == w3.owner_before(w2)); +// change to 'ASSERT_NOEXCEPT' when LWG2942 is adopted + LIBCPP_ASSERT_NOEXCEPT(w1.owner_before(w2)); } diff --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html index 653a897f7c4a..1dc51743b474 100644 --- a/libcxx/www/cxx1z_status.html +++ b/libcxx/www/cxx1z_status.html @@ -465,11 +465,11 @@ 2853Possible inconsistency in specification of erase in [vector.modifiers]Kona 2855std::throw_with_nested("string_literal")Kona 2857{variant,optional,any}::emplace should return the constructed valueKona - 2861basic_string should require that charT match traits::char_typeKonaClow + 2861basic_string should require that charT match traits::char_typeKonaComplete 2866Incorrect derived classes constraintsKona 2868Missing specification of bad_any_cast::what()KonaComplete 2872Add definition for direct-non-list-initializationKonaComplete - 2873Add noexcept to several shared_ptr related functionsKona + 2873Add noexcept to several shared_ptr related functionsKonaComplete 2874Constructor shared_ptr::shared_ptr(Y*) should be constrainedKona 2875shared_ptr::shared_ptr(Y*, D, […]) constructors should be constrainedKona 2876shared_ptr::shared_ptr(const weak_ptr<Y>&) constructor should be constrainedKona