S
salvo
I'm trying to make a case-insensitive class. Here is the code.
=================================Code=================================
#include<bits/char_traits.h>
struct ci_char_traits : public char_traits<char>
{
static bool eq( char c1, char c2 )
{
return toupper(c1) == toupper(c2);
}
static bool lt( char c1, char c2 )
{
return toupper(c1) < toupper(c2);
}
static int compare( const char *s1, const char *s2, size_t n )
{
/*TODO*/
}
static const char* find( const char* s, int n, char a )
{
while( n-- > 0 && toupper(*s) != toupper(a) )
{
++s;
}
return n >= 0 ? s : 0;
}
};
typedef basic_string<char, ci_char_traits> ci_string;
=============================================================
===============================Error==========================
emitrax@freek ~/programming/C++ $ g++ test_ci_string.cc -o test_ci_string
In file included from test_ci_string.cc:3:
ci_string/ci_string.h:30: error: parse error before `<' token
ci_string/ci_string.h:55: error: parse error before `}' token
ci_string/ci_string.h:57: error: syntax error before `;' token
test_ci_string.cc: In function `int main()':
test_ci_string.cc:7: error: `ci_string' undeclared in namespace `std'
test_ci_string.cc:7: error: parse error before `;' token
emitrax@freek ~/programming/C++ $
=============================================================
Can anyone help me?
Thanks
Salvo.
=================================Code=================================
#include<bits/char_traits.h>
struct ci_char_traits : public char_traits<char>
{
static bool eq( char c1, char c2 )
{
return toupper(c1) == toupper(c2);
}
static bool lt( char c1, char c2 )
{
return toupper(c1) < toupper(c2);
}
static int compare( const char *s1, const char *s2, size_t n )
{
/*TODO*/
}
static const char* find( const char* s, int n, char a )
{
while( n-- > 0 && toupper(*s) != toupper(a) )
{
++s;
}
return n >= 0 ? s : 0;
}
};
typedef basic_string<char, ci_char_traits> ci_string;
=============================================================
===============================Error==========================
emitrax@freek ~/programming/C++ $ g++ test_ci_string.cc -o test_ci_string
In file included from test_ci_string.cc:3:
ci_string/ci_string.h:30: error: parse error before `<' token
ci_string/ci_string.h:55: error: parse error before `}' token
ci_string/ci_string.h:57: error: syntax error before `;' token
test_ci_string.cc: In function `int main()':
test_ci_string.cc:7: error: `ci_string' undeclared in namespace `std'
test_ci_string.cc:7: error: parse error before `;' token
emitrax@freek ~/programming/C++ $
=============================================================
Can anyone help me?
Thanks
Salvo.