Share via


regex_traits::locale_type

The type of the stored locale object.

typedef T7 locale_type;

Remarks

The typedef is a synonym for a type that encapsulates locales. In the specializations regex_traits<char> and regex_traits<wchar_t> it is a synonym for std::locale.

Example

 

// std_tr1__regex__regex_traits_locale_type.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
 
typedef std::regex_traits<char> Mytr; 
int main() 
    { 
    Mytr tr; 
 
    Mytr::char_type ch = tr.translate('a'); 
    std::cout << "translate('a') == 'a' == " << std::boolalpha 
        << (ch == 'a') << std::endl; 
 
    std::cout << "nocase 'a' == 'A' == " << std::boolalpha 
        << (tr.translate_nocase('a') == tr.translate_nocase('A')) 
        << std::endl; 
 
    const char *lbegin = "abc"; 
    const char *lend = lbegin + strlen(lbegin); 
    Mytr::size_type size = tr.length(lbegin); 
    std::cout << "length(\"abc\") == " << size <<std::endl; 
 
    Mytr::string_type str = tr.transform(lbegin, lend); 
    std::cout << "transform(\"abc\") < \"abc\" == " << std::boolalpha 
        << (str < "abc") << std::endl; 
 
    const char *ubegin = "ABC"; 
    const char *uend = ubegin + strlen(ubegin); 
    std::cout << "primary \"ABC\" < \"abc\" == " << std::boolalpha 
        << (tr.transform_primary(ubegin, uend) < 
            tr.transform_primary(lbegin, lend)) 
        << std::endl; 
 
    const char *dig = "digit"; 
    Mytr::char_class_type cl = tr.lookup_classname(dig, dig + 5); 
    std::cout << "class digit == d == " << std::boolalpha 
        << (cl == tr.lookup_classname(dig, dig + 1)) 
        << std::endl; 
 
    std::cout << "'3' is digit == " <<std::boolalpha 
        << tr.isctype('3', tr.lookup_classname(dig, dig + 5)) 
        << std::endl; 
 
    std::cout << "hex C == " << tr.value('C', 16) << std::endl; 
 
// other members 
    str = tr.lookup_collatename(dig, dig + 5); 
 
    Mytr::locale_type loc = tr.getloc(); 
    tr.imbue(loc); 
 
    return (0); 
    } 
 
translate('a') == 'a' == true
nocase 'a' == 'A' == true
length("abc") == 3
transform("abc") < "abc" == false
primary "ABC" < "abc" == false
class digit == d == true
'3' is digit == true
hex C == 12

Requirements

Header: <regex>

Namespace: std

See Also

Reference

<regex>

regex_traits Class

Other Resources

<regex> Members