std::char_traits and operators << >>
От: NKZ  
Дата: 04.11.04 10:01
Оценка:
Всем Привет.

Есть вот такой traits класс для basic_string:


#include <tchar.h>
#include <string>

template<typename T>
struct case_traits : public std::char_traits<T>
{
    static bool eq(const char_type& c1, const char_type& c2) 
    {
        return tolower(c1) == tolower(c1); 
    }
    static bool lt(const char_type& c1, const char_type& c2) 
    { 
        return tolower(c1) < tolower(c1); 
    }
};

typedef std::basic_string<TCHAR, case_traits<TCHAR>, std::allocator<TCHAR> > tstring;


void test()
{
    tstring strTest(_T("test"));
    std::cout << strTest;
}


При использовании моего case_traits возникает ошибка:
binary '<<' : no operator found which takes a right-hand operand of type 'const tstring' (or there is no acceptable conversion)
Если же использовать стандартный char_traits то все ОК. По идее должен вызываться: basic_ostream:: operator<<.

Используется STLport-4.6
... << RSDN@Home 1.1.4 beta 3 rev. 0>>
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.