std::basic_regex 的推导指引

出自cppreference.com
< cpp‎ | regex‎ | basic regex


在標頭 <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()}; // 使用显式推导指引
}