]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Reduce template instantiations in <regex>
authorJonathan Wakely <jwakely@redhat.com>
Fri, 17 Dec 2021 18:04:28 +0000 (18:04 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 5 Jan 2022 13:47:01 +0000 (13:47 +0000)
commite09366718ad8c93678618a47016e18cb6e927131
tree68ba1bd45d0963ee49e07fc2923d4d8b80f9ab45
parent9a2451c1013c21e76da89df89c3c8e5e6afe6154
libstdc++: Reduce template instantiations in <regex>

This moves the last two template parameters of __regex_algo_impl to be
runtime function parameters instead, so that we don't need four
different instantiations for the possible ways to call it. Most of the
function (and what it instantiates) is the same in all cases, so making
them compile-time choices doesn't really have much benefit.

Use  'if constexpr' for conditions that check template parameters, so
that when we do depend on a compile-time condition we only instantiate
what we need to.

libstdc++-v3/ChangeLog:

* include/bits/regex.h (__regex_algo_impl): Change __policy and
__match_mode template parameters to be function parameters.
(regex_match, regex_search): Pass policy and match mode as
function arguments.
* include/bits/regex.tcc (__regex_algo_impl): Change template
parameters to function parameters.
* include/bits/regex_compiler.h (_RegexTranslatorBase): Use
'if constexpr' for conditions using template parameters.
(_RegexTranslator): Likewise.
* include/bits/regex_executor.tcc (_Executor::_M_handle_accept):
Likewise.
* testsuite/util/testsuite_regex.h (regex_match_debug)
(regex_search_debug): Move template arguments to function
arguments.
libstdc++-v3/include/bits/regex.h
libstdc++-v3/include/bits/regex.tcc
libstdc++-v3/include/bits/regex_compiler.h
libstdc++-v3/include/bits/regex_executor.tcc
libstdc++-v3/testsuite/util/testsuite_regex.h