42 #ifdef ALPHANUM_LOCALE 63 #ifdef ALPHANUM_LOCALE 65 bool alphanum_isdigit(
int c)
74 bool alphanum_isdigit(
const char c)
76 return c>=
'0' && c<=
'9';
95 int alphanum_impl(
const char *l,
const char *r)
104 while((l_char=*l) && (r_char=*r))
107 const bool l_digit=alphanum_isdigit(l_char), r_digit=alphanum_isdigit(r_char);
109 if(l_digit && r_digit)
115 if(l_digit)
return -1;
117 if(r_digit)
return +1;
119 const int diff=l_char - r_char;
121 if(diff != 0)
return diff;
129 #ifdef ALPHANUM_LOCALE 132 unsigned long l_int=strtoul(l, &end, 0);
136 unsigned long r_int=strtoul(r, &end, 0);
140 unsigned long l_int=0;
141 while(*l && alphanum_isdigit(*l))
144 l_int=l_int*10 + *l-
'0';
149 unsigned long r_int=0;
150 while(*r && alphanum_isdigit(*r))
153 r_int=r_int*10 + *r-
'0';
159 const long diff=l_int-r_int;
183 template <
typename lT,
typename rT>
187 std::clog <<
"alphanum_comp<" <<
typeid(left).
name() <<
"," <<
typeid(right).
name() <<
"> " << left <<
"," << right << std::endl;
189 std::ostringstream l; l << left;
190 std::ostringstream r; r << right;
191 return alphanum_impl(l.str().c_str(), r.str().c_str());
202 int alphanum_comp<std::string>(
const std::string& l,
const std::string& r)
205 std::clog <<
"alphanum_comp<std::string,std::string> " << l <<
"," << r << std::endl;
207 return alphanum_impl(l.c_str(), r.c_str());
228 std::clog <<
"alphanum_comp<char*,char*> " << l <<
"," << r << std::endl;
230 return alphanum_impl(l, r);
238 std::clog <<
"alphanum_comp<const char*,const char*> " << l <<
"," << r << std::endl;
240 return alphanum_impl(l, r);
248 std::clog <<
"alphanum_comp<char*,const char*> " << l <<
"," << r << std::endl;
250 return alphanum_impl(l, r);
258 std::clog <<
"alphanum_comp<const char*,char*> " << l <<
"," << r << std::endl;
260 return alphanum_impl(l, r);
267 std::clog <<
"alphanum_comp<std::string,char*> " << l <<
"," << r << std::endl;
269 return alphanum_impl(l.c_str(), r);
276 std::clog <<
"alphanum_comp<char*,std::string> " << l <<
"," << r << std::endl;
278 return alphanum_impl(l, r.c_str());
285 std::clog <<
"alphanum_comp<std::string,const char*> " << l <<
"," << r << std::endl;
287 return alphanum_impl(l.c_str(), r);
294 std::clog <<
"alphanum_comp<const char*,std::string> " << l <<
"," << r << std::endl;
296 return alphanum_impl(l, r.c_str());
int alphanum_comp(const lT &left, const rT &right)
bool operator()(const Ty &left, const Ty &right) const