std::regex_iterator<BidirIt,CharT,Traits>::regex_iterator

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

# 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

DRApplied toBehavior as publishedCorrect behavior
LWG 2332C++11a regex_iterator constructed from a temporarybasic_regex became invalid immediatelysuch construction is disallowed via a deleted overload