Udostępnij za pośrednictwem


swap Function <regex>

Zamienia dwa obiekty basic_regex lub match_results.

template<class Elem, class RXtraits>
    void swap(basic_regex<Elem, RXtraits, Alloc>& left,
        basic_regex<Elem, RXtraits>& right) throw();
template<class Elem, class IOtraits, class BidIt, class Alloc>
    void swap(match_results<BidIt, Alloc>& left,
        match_results<BidIt, Alloc>& right) throw();

Parametry

  • Elem
    Typ elementów, aby dopasować.

  • RXtraits
    Cech klasy elementów.

Uwagi

Funkcje szablonu Zamień zawartość swoich odpowiednich argumentów w czasie stałe i nie generują wyjątki.

Przykład

 

// std_tr1__regex__swap.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
 
int main() 
    { 
    std::regex rx0("c(a*)|(b)"); 
    std::regex rx1; 
    std::cmatch mr0; 
    std::cmatch mr1; 
 
    swap(rx0, rx1); 
    std::regex_search("xcaaay", mr1, rx1); 
    swap(mr0, mr1); 
 
    std::csub_match sub = mr0[1]; 
    std::cout << "matched == " << std::boolalpha 
        << sub.matched << std::endl; 
    std::cout << "length == " << sub.length() << std::endl; 
    std::cout << "string == " << sub << std::endl; 
 
    return (0); 
    } 
 
  

Wymagania

Nagłówek: <regex>

Obszar nazw: std

Zobacz też

Informacje

<regex>

basic_regex Class

match_results Class