- regex[meta header]
- std[meta namespace]
- function template[meta id-type]
- cpp11[meta cpp]
namespace std {
template <class charT, class ST, class BiIter>
std::basic_ostream<charT, ST>& operator<<(
std::basic_ostream<charT, ST>& os,
const sub_match<BiIter>& m);
}
- sub_match[link ../sub_match.md]
ストリームへの出力を行う。
テンプレート引数は 3 つあるが、規格上は文字列の出力に使用している operator<<
が charT =
iterator_traits
<BiIter>::value_type
、かつ、ST =
char_traits
<charT>
のバージョンしか存在しない。
#include <iostream>
#include <regex>
#include <string>
int main()
{
const char ca[] = " abc ";
const std::regex re(R"(\w+)");
std::cmatch m;
if (std::regex_search(ca, m, re)) {
std::csub_match sub = m[0];
std::cout << '\'' << sub << '\'' << std::endl;
} else {
std::cout << "not match" << std::endl;
}
}
- std::regex[link ../basic_regex.md]
- std::cmatch[link ../match_results.md]
- std::regex_search[link ../regex_search.md]
- std::csub_match[link ../sub_match.md]
'abc'
- C++11
- Clang: 3.0 [mark verified], 3.1 [mark verified], 3.2 [mark verified], 3.3 [mark verified], 3.4 [mark verified], 3.5 [mark verified], 3.6 [mark verified]
- GCC: 4.9.0 [mark verified], 4.9.1 [mark verified], 5.0.0 [mark verified]
- ICC: ??
- Visual C++: ??