diff options
| -rw-r--r-- | libcxx/include/memory | 28 | ||||
| -rw-r--r-- | libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp | 40 | ||||
| -rw-r--r-- | libcxx/www/cxx1z_status.html | 2 |
3 files changed, 69 insertions, 1 deletions
diff --git a/libcxx/include/memory b/libcxx/include/memory index a162eafe678..bd6167268c3 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -5351,7 +5351,11 @@ weak_ptr<_Tp>::lock() const _NOEXCEPT return __r; } +#if _LIBCPP_STD_VER > 14 +template <class _Tp = void> struct owner_less; +#else template <class _Tp> struct owner_less; +#endif template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY owner_less<shared_ptr<_Tp> > @@ -5385,6 +5389,30 @@ struct _LIBCPP_TYPE_VIS_ONLY owner_less<weak_ptr<_Tp> > {return __x.owner_before(__y);} }; +#if _LIBCPP_STD_VER > 14 +template <> +struct _LIBCPP_TYPE_VIS_ONLY owner_less<void> +{ + template <class _Tp, class _Up> + _LIBCPP_INLINE_VISIBILITY + bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + template <class _Tp, class _Up> + _LIBCPP_INLINE_VISIBILITY + bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + template <class _Tp, class _Up> + _LIBCPP_INLINE_VISIBILITY + bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + template <class _Tp, class _Up> + _LIBCPP_INLINE_VISIBILITY + bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + typedef void is_transparent; +}; +#endif + template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this { 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 d091ae99fc2..bf1719c66ff 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 @@ -30,9 +30,28 @@ // bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; // bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; // }; +// +// Added in C++17 +// template<> struct owner_less<void> +// { +// template<class T, class U> +// bool operator()(shared_ptr<T> const&, shared_ptr<U> const&) const; +// template<class T, class U> +// bool operator()(shared_ptr<T> const&, weak_ptr<U> const&) const; +// template<class T, class U> +// bool operator()(weak_ptr<T> const&, shared_ptr<U> const&) const; +// template<class T, class U> +// bool operator()(weak_ptr<T> const&, weak_ptr<U> const&) const; +// +// typedef unspecified is_transparent; +// }; #include <memory> #include <cassert> +#include <set> +#include "test_macros.h" + +struct X {}; int main() { @@ -79,4 +98,25 @@ int main() assert(cs(w1, p3) || cs(w3, p1)); assert(cs(w3, p1) == cs(w3, p2)); } +#if TEST_STD_VER > 14 + { + std::shared_ptr<int> sp1; + std::shared_ptr<void> sp2; + std::shared_ptr<long> sp3; + std::weak_ptr<int> wp1; + + std::owner_less<> cmp; + cmp(sp1, sp2); + cmp(sp1, wp1); + cmp(sp1, sp3); + cmp(wp1, sp1); + cmp(wp1, wp1); + } + { + // test heterogeneous lookups + std::set<std::shared_ptr<X>, std::owner_less<>> s; + std::shared_ptr<void> vp; + s.find(vp); + } +#endif } diff --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html index be3d5911ae8..9090af4b9e6 100644 --- a/libcxx/www/cxx1z_status.html +++ b/libcxx/www/cxx1z_status.html @@ -75,7 +75,7 @@ <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0092R1.html">P0092R1</a></td><td>LWG</td><td>Polishing <chrono></td><td>Kona</td><td>Complete</td><td>3.8</td></tr> <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0007R1.html">P0007R1</a></td><td>LWG</td><td>Constant View: A proposal for a <tt>std::as_const</tt> helper function template.</td><td>Kona</td><td>In progress</td><td></td></tr> <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0156R0.htm" >P0156R0</a></td><td>LWG</td><td>Variadic lock_guard(rev 3).</td><td>Kona</td><td></td><td></td></tr> - <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0074R0.html">P0074R0</a></td><td>LWG</td><td>Making <tt>std::owner_less</tt> more flexible</td><td>Kona</td><td></td><td></td></tr> + <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0074R0.html">P0074R0</a></td><td>LWG</td><td>Making <tt>std::owner_less</tt> more flexible</td><td>Kona</td><td>Complete</td><td>3.8</td></tr> <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0013R1.html">P0013R1</a></td><td>LWG</td><td>Logical type traits rev 2</td><td>Kona</td><td></td><td></td></tr> <!-- <tr><td></td><td></td><td></td><td></td><td></td><td></td></tr> --> </table> |

