I don't know what's wrong with me today, but it's taking way too long to get this little piece of code to compile properly:
Code:
#ifndef STRUTILS_H_INCLUDED_FEB_14_2008
#define STRUTILS_H_INCLUDED_FEB_14_2008
#include <string>
#include <algorithm>
#include <functional>
#include <cctype>
#ifdef UNICODE
# define TCHAR wchar_t
#else
# define TCHAR char
#endif
namespace StrUtils
{
template <typename T>
class CharLessNoCase : public std::binary_function<T, T, bool>
{
bool operator()( T c1, T c2 )
{
return (tolower( static_cast<unsigned T>(c1) ) <
tolower( static_cast<unsigned T>(c1) ));
}
};
template <typename T>
bool StringCompareNoCase( std::basic_string<T>& str1,
std::basic_string<T>& str2 )
{
return std::lexicographical_compare( str1.begin(), str1.end(),
str2.begin(), str2.end(),
CharLessNoCase<T>() );
}
}
#endif // STRUTILS_H_INCLUDED_FEB_14_2008
VC++ 6.0 is saying:
c:\program files\microsoft visual studio 6.0\vc98\include\xutility(60) : error C2248: '()' : cannot access private member declared in class 'StrUtils::CharLessNoCase<unsigned short>'
d:\vss_root\devel\include\base\strutils.h(24) : see declaration of '()'
d:\vss_root\devel\include\base\strutils.h(38) : see reference to function template instantiation 'bool __cdecl std::lexicographical_compare(unsigned short *,unsigned short *,unsigned short *,unsigned short *,class StrUtils::CharLessNoCase<unsigned short>)' being compiled
Even Comeau is choking on it, so it has to be something I'm doing wrong, but I just can't see what it is...