std::regex_iterator<BidirIt,CharT,Traits>::regex_iterator
Min standard notice:
Constructs a new regex_iterator:
# Declarations
regex_iterator();
(since C++11)
regex_iterator( BidirIt a, BidirIt b,
const regex_type& re,
std::regex_constants::match_flag_type m =
std::regex_constants::match_default );
(since C++11)
regex_iterator( const regex_iterator& );
(since C++11)
regex_iterator( BidirIt, BidirIt,
const regex_type&&,
std::regex_constants::match_flag_type =
std::regex_constants::match_default ) = delete;
(since C++11)
# Parameters
a: LegacyBidirectionalIterator to the beginning of the target character sequenceb: LegacyBidirectionalIterator to the end of the target character sequencere: regular expression used to search the target character sequencem: flags that govern the behavior of re
# Example
#include <iostream>
#include <regex>
#include <string_view>
int main()
{
constexpr std::string_view str{R"(
#ONE: *p = &Mass;
#Two: MOV %rd, 42
)"};
const std::regex re("[a-w]");
// create regex_iterator, overload (2)
auto it = std::regex_iterator<std::string_view::iterator>
{
str.cbegin(), str.cend(),
re // re is lvalue; if an immediate expression was used
// instead, e.g. std::regex{"[a-z]"}, this would
// produce an error since overload (4) is deleted
};
for (decltype(it) last /* overload (1) */; it != last; ++it)
std::cout << (*it).str();
std::cout << '\n';
}
# Defect reports
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2332 | C++11 | a regex_iterator constructed from a temporarybasic_regex became invalid immediately | such construction is disallowed via a deleted overload |