Translate exceptions by const reference instead of plain ref

This commit is contained in:
Martin Hořeňovský
2020-05-19 21:23:35 +02:00
parent 4b2f1da02a
commit 4394d3ae65
3 changed files with 8 additions and 8 deletions

View File

@@ -12,7 +12,7 @@ namespace Catch {
class ExceptionTranslator : public IExceptionTranslator {
public:
ExceptionTranslator( std::string(*translateFunction)( T& ) )
ExceptionTranslator( std::string(*translateFunction)( T const& ) )
: m_translateFunction( translateFunction )
{}
@@ -24,7 +24,7 @@ namespace Catch {
else
return (*it)->translate( it+1, itEnd );
}
catch( T& ex ) {
catch( T const& ex ) {
return m_translateFunction( ex );
}
#else
@@ -33,12 +33,12 @@ namespace Catch {
}
protected:
std::string(*m_translateFunction)( T& );
std::string(*m_translateFunction)( T const& );
};
public:
template<typename T>
ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
ExceptionTranslatorRegistrar( std::string(*translateFunction)( T const& ) ) {
getMutableRegistryHub().registerTranslator
( new ExceptionTranslator<T>( translateFunction ) );
}