Skip to content
Snippets Groups Projects
Commit 3e1abd7c authored by Jan Travnicek's avatar Jan Travnicek
Browse files

fix primitive comparisons

parent 0f1434aa
No related branches found
No related tags found
1 merge request!95Many clang-tidy fixes
Pipeline #40787 passed with warnings
...@@ -138,7 +138,7 @@ struct compare < unsigned char > { ...@@ -138,7 +138,7 @@ struct compare < unsigned char > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( unsigned char first, unsigned char second ) const { int operator ( ) ( unsigned char first, unsigned char second ) const {
return first - second; return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
} }
}; };
   
...@@ -159,7 +159,7 @@ struct compare < signed char > { ...@@ -159,7 +159,7 @@ struct compare < signed char > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( signed char first, signed char second ) const { int operator ( ) ( signed char first, signed char second ) const {
return first - second; return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
} }
}; };
   
...@@ -180,7 +180,7 @@ struct compare < char > { ...@@ -180,7 +180,7 @@ struct compare < char > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( char first, char second ) const { int operator ( ) ( char first, char second ) const {
return first - second; return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
} }
}; };
   
...@@ -201,7 +201,7 @@ struct compare < unsigned short > { ...@@ -201,7 +201,7 @@ struct compare < unsigned short > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( unsigned short first, unsigned short second ) const { int operator ( ) ( unsigned short first, unsigned short second ) const {
return first - second; return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
} }
}; };
   
...@@ -222,7 +222,7 @@ struct compare < signed short > { ...@@ -222,7 +222,7 @@ struct compare < signed short > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator()(signed short first, signed short second) const { int operator()(signed short first, signed short second) const {
return first - second; return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
} }
}; };
   
...@@ -243,7 +243,7 @@ struct compare < unsigned int > { ...@@ -243,7 +243,7 @@ struct compare < unsigned int > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator()(unsigned int first, unsigned int second) const { int operator()(unsigned int first, unsigned int second) const {
return first - second; return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
} }
}; };
   
...@@ -264,7 +264,7 @@ struct compare < signed int > { ...@@ -264,7 +264,7 @@ struct compare < signed int > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator()(signed int first, signed int second) const { int operator()(signed int first, signed int second) const {
return first - second; return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
} }
}; };
   
...@@ -285,12 +285,7 @@ struct compare < unsigned long > { ...@@ -285,12 +285,7 @@ struct compare < unsigned long > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( unsigned long first, unsigned long second ) const { int operator ( ) ( unsigned long first, unsigned long second ) const {
if ( first < second ) return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
return -1;
else if ( first > second )
return 1;
else
return 0;
} }
}; };
   
...@@ -311,12 +306,7 @@ struct compare < signed long > { ...@@ -311,12 +306,7 @@ struct compare < signed long > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( signed long first, signed long second ) const { int operator ( ) ( signed long first, signed long second ) const {
if ( first < second ) return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
return -1;
else if ( first > second )
return 1;
else
return 0;
} }
}; };
   
...@@ -337,12 +327,7 @@ struct compare < unsigned long long > { ...@@ -337,12 +327,7 @@ struct compare < unsigned long long > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( unsigned long long first, unsigned long long second ) const { int operator ( ) ( unsigned long long first, unsigned long long second ) const {
if ( first < second ) return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
return -1;
else if ( first > second )
return 1;
else
return 0;
} }
}; };
   
...@@ -363,12 +348,7 @@ struct compare < signed long long > { ...@@ -363,12 +348,7 @@ struct compare < signed long long > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( signed long long first, signed long long second ) const { int operator ( ) ( signed long long first, signed long long second ) const {
if ( first < second ) return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
return -1;
else if ( first > second )
return 1;
else
return 0;
} }
}; };
   
...@@ -389,12 +369,7 @@ struct compare < float > { ...@@ -389,12 +369,7 @@ struct compare < float > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( float first, float second ) const { int operator ( ) ( float first, float second ) const {
if ( first < second ) return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
return -1;
else if ( first > second )
return 1;
else
return 0;
} }
}; };
   
...@@ -415,12 +390,7 @@ struct compare < double > { ...@@ -415,12 +390,7 @@ struct compare < double > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( double first, double second ) const { int operator ( ) ( double first, double second ) const {
if ( first < second ) return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
return -1;
else if ( first > second )
return 1;
else
return 0;
} }
}; };
   
...@@ -441,12 +411,7 @@ struct compare < long double > { ...@@ -441,12 +411,7 @@ struct compare < long double > {
* \return negative value of left < right, positive value if left > right, zero if left == right * \return negative value of left < right, positive value if left > right, zero if left == right
*/ */
int operator ( ) ( long double first, long double second ) const { int operator ( ) ( long double first, long double second ) const {
if ( first < second ) return static_cast < int > ( second < first ) - static_cast < int > ( first < second );
return -1;
else if ( first > second )
return 1;
else
return 0;
} }
}; };
   
......
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