“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}}
{{dcl begin}}
+
{{headerregex|since=c++17|1=
{{dcl header|regex}}
+
template< class ForwardIt >
{{dcl | since=c++17 |1=
+
basic_regex( ForwardIt, ForwardIt,
template<class ForwardIt>  
+
std::regex_constants::syntax_option_type = std::regex_constants::ECMAScript )
basic_regex(ForwardIt, ForwardIt,
+
            std::regex_constants::syntax_option_type = std::regex_constants::ECMAScript)
+
 
-> basic_regex<typename std::iterator_traits<ForwardIt>::value_type>;
 
-> basic_regex<typename std::iterator_traits<ForwardIt>::value_type>;
 
}}
 
}}
{{dcl end}}
 
  
 为 {{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的最后版本


 
 
 
正则表达式库
(C++11)
算法
迭代器
异常
特征
常量
(C++11)
正则表达式文法
 
 
在标头 <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()}; // 使用显式推导指引
}