Namespaces
Variants

deduction guides for std::basic_regex

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
Traits
Constants
(C++11)
Regex Grammar
定义于头文件 <regex>
template < class ForwardIt >

basic_regex ( ForwardIt, ForwardIt,
std:: regex_constants :: syntax_option_type = std:: regex_constants :: ECMAScript )

- > basic_regex < typename std:: iterator_traits < ForwardIt > :: value_type > ;
(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()); // 使用显式推导指南
}