From 249bf116e8e384889bced2c675ba118a165647b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 1 Aug 2017 22:09:32 +0200 Subject: [PATCH] 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. --- include/internal/catch_evaluate.hpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/include/internal/catch_evaluate.hpp b/include/internal/catch_evaluate.hpp index 730032fd..9d9da64c 100644 --- a/include/internal/catch_evaluate.hpp +++ b/include/internal/catch_evaluate.hpp @@ -91,6 +91,11 @@ namespace Internal { return Evaluator::evaluate( lhs, rhs ); } + template + bool compare( void const* lhs, void const* rhs ) { + return Evaluator::evaluate( lhs, rhs ); + } + // unsigned X to int template bool compare( unsigned int lhs, int rhs ) { return applyEvaluator( lhs, static_cast( rhs ) ); @@ -137,18 +142,18 @@ namespace Internal { // pointer to long (when comparing against NULL) template bool compare( long lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); + return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); } template bool compare( T* lhs, long rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); + return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); } // pointer to int (when comparing against NULL) template bool compare( int lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); + return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); } template bool compare( T* lhs, int rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); + return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); } // long long to unsigned X @@ -181,18 +186,18 @@ namespace Internal { // pointer to long long (when comparing against NULL) template bool compare( long long lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); + return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); } template bool compare( T* lhs, long long rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); + return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); } // pointer to nullptr_t (when comparing against nullptr) template bool compare( std::nullptr_t, T* rhs ) { - return Evaluator::evaluate( nullptr, rhs ); + return Evaluator::evaluate( nullptr, rhs ); } template bool compare( T* lhs, std::nullptr_t ) { - return Evaluator::evaluate( lhs, nullptr ); + return Evaluator::evaluate( lhs, nullptr ); } } // end of namespace Internal