Export (0) Print
Expand All

basic_regex::getloc

Returns the stored locale object.

locale_type getloc() const;

The member function returns traits.regex_traits::getloc().

 

// std_tr1__regex__basic_regex_getloc.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
 
int main() 
    { 
    std::regex::value_type elem = 'x'; 
    std::regex::flag_type flag = std::regex::grep; 
 
    elem = elem;  // to quiet "unused" warnings 
    flag = flag; 
 
// constructors 
    std::regex rx0; 
    std::cout << "match(\"abc\", \"\") == " << std::boolalpha 
        << regex_match("abc", rx0) << std::endl; 
 
    std::regex rx1("abcd", std::regex::ECMAScript); 
    std::cout << "match(\"abc\", \"abcd\") == " << std::boolalpha 
        << regex_match("abc", rx1) << std::endl; 
 
    std::regex rx2("abcd", 3); 
    std::cout << "match(\"abc\", \"abc\") == " << std::boolalpha 
        << regex_match("abc", rx2) << std::endl; 
 
    std::regex rx3(rx2); 
    std::cout << "match(\"abc\", \"abc\") == " << std::boolalpha 
        << regex_match("abc", rx3) << std::endl; 
 
    std::string str("abcd"); 
    std::regex rx4(str); 
    std::cout << "match(string(\"abcd\"), \"abc\") == " << std::boolalpha 
        << regex_match("abc", rx4) << std::endl; 
 
    std::regex rx5(str.begin(), str.end() - 1); 
    std::cout << "match(string(\"abc\"), \"abc\") == " << std::boolalpha 
        << regex_match("abc", rx5) << std::endl; 
    std::cout << std::endl; 
 
// assignments 
    rx0 = "abc"; 
    rx0 = rx1; 
    rx0 = str; 
 
    rx0.assign("abcd", std::regex::ECMAScript); 
    rx0.assign("abcd", 3); 
    rx0.assign(rx1); 
    rx0.assign(str); 
    rx0.assign(str.begin(), str.end() - 1); 
 
    rx0.swap(rx1); 
 
// mark_count 
    std::cout << "\"abc\" mark_count == " 
        << std::regex("abc").mark_count() << std::endl; 
    std::cout << "\"(abc)\" mark_count == " 
        << std::regex("(abc)").mark_count() << std::endl; 
 
// locales 
    std::regex::locale_type loc = rx0.imbue(std::locale()); 
    std::cout << "getloc == imbued == " << std::boolalpha 
        << (loc == rx0.getloc()) << std::endl; 
 
    return (0); 
    } 
 
match("abc", "") == false
match("abc", "abcd") == false
match("abc", "abc") == true
match("abc", "abc") == true
match(string("abcd"), "abc") == false
match(string("abc"), "abc") == true

"abc" mark_count == 0
"(abc)" mark_count == 1
getloc == imbued == true

Header: <regex>

Namespace: std

Community Additions

ADD
Show:
© 2014 Microsoft