Export (0) Print
Expand All

regex_traits::transform_primary

Converts to equivalent caseless ordered sequence.

template<class FwdIt>
    string_type transform_primary(FwdIt first, FwdIt last) const;

first

Beginning of sequence to transform.

last

End of sequence to transform.

The member function returns a string that it generates by using a transformation rule that depends on the stored locale object. For two character sequences designated by the iterator ranges [first1, last1) and [first2, last2), transform_primary(first1, last1) < transform_primary(first2, last2) if the character sequence designated by the iterator range [first1, last1) sorts before the character sequence designated by the iterator range [first2, last2) without regard for case or accents.

 

// std_tr1__regex__regex_traits_transform_primary.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
 
typedef std::tr1::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

Header: <regex>

Namespace: std::tr1

Community Additions

ADD
Show:
© 2014 Microsoft