From d4a9dffbaaf1e53648ee102a93bdcb3edb2f137e Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 10 Nov 2015 15:12:24 +0000 Subject: [PATCH] Fix return type of heterogeneous find for sets PR libstdc++/68190 * include/bits/stl_multiset.h (multiset::find): Fix return types. * include/bits/stl_set.h (set::find): Likewise. * testsuite/23_containers/map/operations/2.cc: Test find return types. * testsuite/23_containers/multimap/operations/2.cc: Likewise. * testsuite/23_containers/multiset/operations/2.cc: Likewise. * testsuite/23_containers/set/operations/2.cc: Likewise. From-SVN: r230113 --- libstdc++-v3/ChangeLog | 8 ++++++++ libstdc++-v3/include/bits/stl_multiset.h | 10 ++++++---- libstdc++-v3/include/bits/stl_set.h | 10 ++++++---- .../testsuite/23_containers/map/operations/2.cc | 5 +++++ .../testsuite/23_containers/multimap/operations/2.cc | 5 +++++ .../testsuite/23_containers/multiset/operations/2.cc | 5 +++++ .../testsuite/23_containers/set/operations/2.cc | 5 +++++ 7 files changed, 40 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 76d982aa8f0..5d41876ac57 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2015-11-10 Jonathan Wakely + PR libstdc++/68190 + * include/bits/stl_multiset.h (multiset::find): Fix return types. + * include/bits/stl_set.h (set::find): Likewise. + * testsuite/23_containers/map/operations/2.cc: Test find return types. + * testsuite/23_containers/multimap/operations/2.cc: Likewise. + * testsuite/23_containers/multiset/operations/2.cc: Likewise. + * testsuite/23_containers/set/operations/2.cc: Likewise. + * doc/xml/manual/status_cxx2017.xml: Update. * doc/html/*: Regenerate. diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index 5ccc6dd61f7..e6e233772b3 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -680,13 +680,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus > 201103L template auto - find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x)) - { return _M_t._M_find_tr(__x); } + find(const _Kt& __x) + -> decltype(iterator{_M_t._M_find_tr(__x)}) + { return iterator{_M_t._M_find_tr(__x)}; } template auto - find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x)) - { return _M_t._M_find_tr(__x); } + find(const _Kt& __x) const + -> decltype(const_iterator{_M_t._M_find_tr(__x)}) + { return const_iterator{_M_t._M_find_tr(__x)}; } #endif //@} diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index cf74368fa0e..8bea61a3b23 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -699,13 +699,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus > 201103L template auto - find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x)) - { return _M_t._M_find_tr(__x); } + find(const _Kt& __x) + -> decltype(iterator{_M_t._M_find_tr(__x)}) + { return iterator{_M_t._M_find_tr(__x)}; } template auto - find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x)) - { return _M_t._M_find_tr(__x); } + find(const _Kt& __x) const + -> decltype(const_iterator{_M_t._M_find_tr(__x)}) + { return const_iterator{_M_t._M_find_tr(__x)}; } #endif //@} diff --git a/libstdc++-v3/testsuite/23_containers/map/operations/2.cc b/libstdc++-v3/testsuite/23_containers/map/operations/2.cc index 6cc277aedce..ef301ef136c 100644 --- a/libstdc++-v3/testsuite/23_containers/map/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/map/operations/2.cc @@ -54,6 +54,11 @@ test01() VERIFY( cit == cx.end() ); VERIFY( Cmp::count == 0); + + static_assert(std::is_same::value, + "find returns iterator"); + static_assert(std::is_same::value, + "const find returns const_iterator"); } void diff --git a/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc b/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc index 67c3bfd60a3..eef6ee4515d 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc @@ -54,6 +54,11 @@ test01() VERIFY( cit == cx.end() ); VERIFY( Cmp::count == 0); + + static_assert(std::is_same::value, + "find returns iterator"); + static_assert(std::is_same::value, + "const find returns const_iterator"); } void diff --git a/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc b/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc index ff2748f713a..4bea719160f 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc @@ -54,6 +54,11 @@ test01() VERIFY( cit == cx.end() ); VERIFY( Cmp::count == 0); + + static_assert(std::is_same::value, + "find returns iterator"); + static_assert(std::is_same::value, + "const find returns const_iterator"); } void diff --git a/libstdc++-v3/testsuite/23_containers/set/operations/2.cc b/libstdc++-v3/testsuite/23_containers/set/operations/2.cc index 84ddd1f1ddc..6a68453ec7b 100644 --- a/libstdc++-v3/testsuite/23_containers/set/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/set/operations/2.cc @@ -54,6 +54,11 @@ test01() VERIFY( cit == cx.end() ); VERIFY( Cmp::count == 0); + + static_assert(std::is_same::value, + "find returns iterator"); + static_assert(std::is_same::value, + "const find returns const_iterator"); } void -- 2.30.2