From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [patch] libstdc++/68190 Fix return type of heterogeneous find for sets
Date: Tue, 10 Nov 2015 15:12:00 -0000 [thread overview]
Message-ID: <20151110151229.GF2937@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 180 bytes --]
This converts the return type of heterogeneous find members to the
correct set iterator type.
Tested powerpc64le-linux, committed to trunk. Will commit to the
gcc-5-branch too.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 4780 bytes --]
commit d84e13dd8a7d47016bdfc5a9f45d8658a9d16ed9
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Nov 10 14:59:00 2015 +0000
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.
diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h
index 5ccc6dd..e6e2337 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<typename _Kt>
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<typename _Kt>
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 cf74368..8bea61a 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<typename _Kt>
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<typename _Kt>
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 6cc277a..ef301ef 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<decltype(it), test_type::iterator>::value,
+ "find returns iterator");
+ static_assert(std::is_same<decltype(cit), test_type::const_iterator>::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 67c3bfd..eef6ee4 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<decltype(it), test_type::iterator>::value,
+ "find returns iterator");
+ static_assert(std::is_same<decltype(cit), test_type::const_iterator>::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 ff2748f..4bea719 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<decltype(it), test_type::iterator>::value,
+ "find returns iterator");
+ static_assert(std::is_same<decltype(cit), test_type::const_iterator>::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 84ddd1f..6a68453 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<decltype(it), test_type::iterator>::value,
+ "find returns iterator");
+ static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value,
+ "const find returns const_iterator");
}
void
reply other threads:[~2015-11-10 15:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151110151229.GF2937@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).