mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-04 05:09:53 +01:00
Route all T* comparisons through const void* comparisons
This should stop the evaluate machinery from instantiating all the templates for every ptr type that is compared, instead generating it for single one.
This commit is contained in:
parent
6d4673505d
commit
249bf116e8
@ -91,6 +91,11 @@ namespace Internal {
|
|||||||
return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
|
return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<Operator Op>
|
||||||
|
bool compare( void const* lhs, void const* rhs ) {
|
||||||
|
return Evaluator<void const*, void const*, Op>::evaluate( lhs, rhs );
|
||||||
|
}
|
||||||
|
|
||||||
// unsigned X to int
|
// unsigned X to int
|
||||||
template<Operator Op> bool compare( unsigned int lhs, int rhs ) {
|
template<Operator Op> bool compare( unsigned int lhs, int rhs ) {
|
||||||
return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
|
return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
|
||||||
@ -137,18 +142,18 @@ namespace Internal {
|
|||||||
|
|
||||||
// pointer to long (when comparing against NULL)
|
// pointer to long (when comparing against NULL)
|
||||||
template<Operator Op, typename T> bool compare( long lhs, T* rhs ) {
|
template<Operator Op, typename T> bool compare( long lhs, T* rhs ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
|
return Evaluator<void const*, void const*, Op>::evaluate( reinterpret_cast<void const*>( lhs ), rhs );
|
||||||
}
|
}
|
||||||
template<Operator Op, typename T> bool compare( T* lhs, long rhs ) {
|
template<Operator Op, typename T> bool compare( T* lhs, long rhs ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
|
return Evaluator<void const*, void const*, Op>::evaluate( lhs, reinterpret_cast<void const*>( rhs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// pointer to int (when comparing against NULL)
|
// pointer to int (when comparing against NULL)
|
||||||
template<Operator Op, typename T> bool compare( int lhs, T* rhs ) {
|
template<Operator Op, typename T> bool compare( int lhs, T* rhs ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
|
return Evaluator<void const*, void const*, Op>::evaluate( reinterpret_cast<void const*>( lhs ), rhs );
|
||||||
}
|
}
|
||||||
template<Operator Op, typename T> bool compare( T* lhs, int rhs ) {
|
template<Operator Op, typename T> bool compare( T* lhs, int rhs ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
|
return Evaluator<void const*, void const*, Op>::evaluate( lhs, reinterpret_cast<void const*>( rhs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// long long to unsigned X
|
// long long to unsigned X
|
||||||
@ -181,18 +186,18 @@ namespace Internal {
|
|||||||
|
|
||||||
// pointer to long long (when comparing against NULL)
|
// pointer to long long (when comparing against NULL)
|
||||||
template<Operator Op, typename T> bool compare( long long lhs, T* rhs ) {
|
template<Operator Op, typename T> bool compare( long long lhs, T* rhs ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
|
return Evaluator<void const*, void const*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
|
||||||
}
|
}
|
||||||
template<Operator Op, typename T> bool compare( T* lhs, long long rhs ) {
|
template<Operator Op, typename T> bool compare( T* lhs, long long rhs ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
|
return Evaluator<void const*, void const*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// pointer to nullptr_t (when comparing against nullptr)
|
// pointer to nullptr_t (when comparing against nullptr)
|
||||||
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
|
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( nullptr, rhs );
|
return Evaluator<void const*, void const*, Op>::evaluate( nullptr, rhs );
|
||||||
}
|
}
|
||||||
template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) {
|
template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( lhs, nullptr );
|
return Evaluator<void const*, void const*, Op>::evaluate( lhs, nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace Internal
|
} // end of namespace Internal
|
||||||
|
Loading…
Reference in New Issue
Block a user