“cpp/regex/basic regex/deduction guides”的版本间的差异
来自cppreference.com
< cpp | regex | basic regex
小 |
小 |
||
第1行: | 第1行: | ||
{{title|{{tt|std::basic_regex}} 的推导指引}} | {{title|{{tt|std::basic_regex}} 的推导指引}} | ||
{{cpp/regex/basic_regex/navbar}} | {{cpp/regex/basic_regex/navbar}} | ||
− | {{ | + | {{headerregex|since=c++17|1= |
− | + | template< class ForwardIt > | |
− | + | basic_regex( ForwardIt, ForwardIt, | |
− | template<class ForwardIt> | + | std::regex_constants::syntax_option_type = std::regex_constants::ECMAScript ) |
− | basic_regex(ForwardIt, ForwardIt, | + | |
− | + | ||
-> basic_regex<typename std::iterator_traits<ForwardIt>::value_type>; | -> basic_regex<typename std::iterator_traits<ForwardIt>::value_type>; | ||
}} | }} | ||
− | |||
− | 为 {{lc|std::basic_regex}} 提供此[[cpp/language/class_template_argument_deduction|推导指引]] | + | 为 {{lc|std::basic_regex}} 提供此[[cpp/language/class_template_argument_deduction|推导指引]],以允许从迭代器范围推导。 |
===示例=== | ===示例=== | ||
− | {{example|code= | + | {{example |
+ | |code= | ||
#include <regex> | #include <regex> | ||
#include <vector> | #include <vector> | ||
− | int main() { | + | |
+ | int main() | ||
+ | { | ||
std::vector<char> v = {'a', 'b', 'c'}; | std::vector<char> v = {'a', 'b', 'c'}; | ||
std::basic_regex re{v.begin(), v.end()}; // 使用显式推导指引 | std::basic_regex re{v.begin(), v.end()}; // 使用显式推导指引 |
2024年3月7日 (四) 06:21的最后版本
在标头 <regex> 定义
|
||
template< class ForwardIt > basic_regex( ForwardIt, ForwardIt, |
(C++17 起) | |
为 std::basic_regex 提供此推导指引,以允许从迭代器范围推导。
[编辑] 示例
运行此代码
#include <regex> #include <vector> int main() { std::vector<char> v = {'a', 'b', 'c'}; std::basic_regex re{v.begin(), v.end()}; // 使用显式推导指引 }