* [committed] libstdc++: Remove <memory_resource> dependency from <regex> [PR 92546]
@ 2020-11-20 13:28 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2020-11-20 13:28 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 997 bytes --]
Unlike the other headers that declare alias templates in namespace pmr,
<regex> includes <memory_resource>. That was done because the
pmr::string::const_iterator typedef requires pmr::string to be complete,
which requires pmr::polymorphic_allocator<char> to be complete.
By using __normal_iterator<const char*, pmr::string> instead of the
const_iterator typedef we can avoid the completeness requirement.
This makes <regex> smaller, by not requiring <memory_resource> and its
<shared_mutex> dependency, which depends on <chrono>. Backporting this
will also help with PR 97876, where <stop_token> ends up being needed by
<regex> via <memory_resource>.
libstdc++-v3/ChangeLog:
PR libstdc++/92546
* include/std/regex (pmr::smatch, pmr::wsmatch): Declare using
underlying __normal_iterator type, not nested typedef
basic_string::const_iterator.
No new test, because 28_regex/match_results/pmr_typedefs.cc already
checks these typedefs are correct.
Tested x86_64-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2549 bytes --]
commit 640ebeb336050887cb57417b7568279c588088f0
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Nov 20 11:30:33 2020
libstdc++: Remove <memory_resource> dependency from <regex> [PR 92546]
Unlike the other headers that declare alias templates in namespace pmr,
<regex> includes <memory_resource>. That was done because the
pmr::string::const_iterator typedef requires pmr::string to be complete,
which requires pmr::polymorphic_allocator<char> to be complete.
By using __normal_iterator<const char*, pmr::string> instead of the
const_iterator typedef we can avoid the completeness requirement.
This makes <regex> smaller, by not requiring <memory_resource> and its
<shared_mutex> dependency, which depends on <chrono>. Backporting this
will also help with PR 97876, where <stop_token> ends up being needed by
<regex> via <memory_resource>.
libstdc++-v3/ChangeLog:
PR libstdc++/92546
* include/std/regex (pmr::smatch, pmr::wsmatch): Declare using
underlying __normal_iterator type, not nested typedef
basic_string::const_iterator.
diff --git a/libstdc++-v3/include/std/regex b/libstdc++-v3/include/std/regex
index 43ee1aee6162..783f5f131a67 100644
--- a/libstdc++-v3/include/std/regex
+++ b/libstdc++-v3/include/std/regex
@@ -64,21 +64,25 @@
#include <bits/regex_executor.h>
#if __cplusplus >= 201703L && _GLIBCXX_USE_CXX11_ABI
-#include <memory_resource>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
- namespace pmr {
+ namespace pmr
+ {
template<typename _Tp> class polymorphic_allocator;
template<typename _BidirectionalIterator>
using match_results
= std::match_results<_BidirectionalIterator, polymorphic_allocator<
sub_match<_BidirectionalIterator>>>;
- using cmatch = match_results<const char*>;
- using smatch = match_results<string::const_iterator>;
+ using cmatch = match_results<const char*>;
+ // Use __normal_iterator directly, because pmr::string::const_iterator
+ // would require pmr::polymorphic_allocator to be complete.
+ using smatch
+ = match_results<__gnu_cxx::__normal_iterator<const char*, string>>;
#ifdef _GLIBCXX_USE_WCHAR_T
using wcmatch = match_results<const wchar_t*>;
- using wsmatch = match_results<wstring::const_iterator>;
+ using wsmatch
+ = match_results<__gnu_cxx::__normal_iterator<const wchar_t*, wstring>>;
#endif
} // namespace pmr
_GLIBCXX_END_NAMESPACE_VERSION
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-20 13:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 13:28 [committed] libstdc++: Remove <memory_resource> dependency from <regex> [PR 92546] Jonathan Wakely
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).