Skip to content
Snippets Groups Projects
Commit 47b9b48d authored by Jan Trávníček's avatar Jan Trávníček
Browse files

add missing compare specs for primitive types

parent ecf70492
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,20 @@ struct compare<bool> {
}
};
 
template<>
struct compare<unsigned char> {
int operator()(unsigned char first, unsigned char second) const {
return first - second;
}
};
template<>
struct compare<signed char> {
int operator()(signed char first, signed char second) const {
return first - second;
}
};
template<>
struct compare<char> {
int operator()(char first, char second) const {
......@@ -30,29 +44,72 @@ struct compare<char> {
};
 
template<>
struct compare<short> {
int operator()(short first, short second) const {
struct compare<unsigned short> {
int operator()(unsigned short first, unsigned short second) const {
return first - second;
}
};
 
template<>
struct compare<unsigned> {
int operator()(unsigned first, unsigned second) const {
struct compare<signed short> {
int operator()(signed short first, signed short second) const {
return first - second;
}
};
 
template<>
struct compare<int> {
int operator()(int first, int second) const {
struct compare<unsigned int> {
int operator()(unsigned int first, unsigned int second) const {
return first - second;
}
};
 
template<>
struct compare<long> {
int operator()(long first, long second) const {
struct compare<signed int> {
int operator()(signed int first, signed int second) const {
return first - second;
}
};
template<>
struct compare<signed long> {
int operator()(signed long first, signed long second) const {
if ( first < second )
return -1;
else if ( first > second )
return 1;
else
return 0;
}
};
template<>
struct compare<unsigned long> {
int operator()(unsigned long first, unsigned long second) const {
if ( first < second )
return -1;
else if ( first > second )
return 1;
else
return 0;
}
};
template<>
struct compare<signed long long> {
int operator()(signed long long first, signed long long second) const {
if ( first < second )
return -1;
else if ( first > second )
return 1;
else
return 0;
}
};
template<>
struct compare<unsigned long long> {
int operator()(unsigned long long first, unsigned long long second) const {
if ( first < second )
return -1;
else if ( first > second )
......@@ -63,8 +120,8 @@ struct compare<long> {
};
 
template<>
struct compare<long long> {
int operator()(long long first, long long second) const {
struct compare<float> {
int operator()(float first, float second) const {
if ( first < second )
return -1;
else if ( first > second )
......@@ -75,8 +132,8 @@ struct compare<long long> {
};
 
template<>
struct compare<double> {
int operator()(double first, double second) const {
struct compare<long double> {
int operator()(long double first, long double second) const {
if ( first < second )
return -1;
else if ( first > second )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment