mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	Hold exception translators by unique_ptr
- and removed range deleters
This commit is contained in:
		| @@ -45,16 +45,6 @@ namespace Catch { | ||||
|         virtual ~NonCopyable(); | ||||
|     }; | ||||
|  | ||||
|     template<typename ContainerT> | ||||
|     void deleteAll( ContainerT& container ) { | ||||
|         for( auto p : container ) | ||||
|             delete p; | ||||
|     } | ||||
|     template<typename AssociativeContainerT> | ||||
|     void deleteAllValues( AssociativeContainerT& container ) { | ||||
|         for( auto const& kvp : container ) | ||||
|             delete kvp.second; | ||||
|     } | ||||
|  | ||||
|     bool startsWith( std::string const& s, std::string const& prefix ); | ||||
|     bool startsWith( std::string const& s, char prefix ); | ||||
|   | ||||
| @@ -16,11 +16,10 @@ | ||||
| namespace Catch { | ||||
|  | ||||
|     ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() { | ||||
|         deleteAll( m_translators ); | ||||
|     } | ||||
|  | ||||
|     void ExceptionTranslatorRegistry::registerTranslator( const IExceptionTranslator* translator ) { | ||||
|         m_translators.push_back( translator ); | ||||
|         m_translators.push_back( std::unique_ptr<const IExceptionTranslator>( translator ) ); | ||||
|     } | ||||
|  | ||||
|     std::string ExceptionTranslatorRegistry::translateActiveException() const { | ||||
|   | ||||
| @@ -11,6 +11,7 @@ | ||||
| #include "catch_interfaces_exception.h" | ||||
| #include <vector> | ||||
| #include <string> | ||||
| #include <memory> | ||||
|  | ||||
| namespace Catch { | ||||
|  | ||||
| @@ -22,7 +23,7 @@ namespace Catch { | ||||
|         std::string tryTranslators() const; | ||||
|  | ||||
|     private: | ||||
|         std::vector<const IExceptionTranslator*> m_translators; | ||||
|         std::vector<std::unique_ptr<IExceptionTranslator const>> m_translators; | ||||
|     }; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -18,7 +18,7 @@ namespace Catch { | ||||
|     typedef std::string(*exceptionTranslateFunction)(); | ||||
|  | ||||
|     struct IExceptionTranslator; | ||||
|     typedef std::vector<const IExceptionTranslator*> ExceptionTranslators; | ||||
|     typedef std::vector<std::unique_ptr<IExceptionTranslator const>> ExceptionTranslators; | ||||
|  | ||||
|     struct IExceptionTranslator { | ||||
|         virtual ~IExceptionTranslator(); | ||||
| @@ -40,7 +40,7 @@ namespace Catch { | ||||
|             : m_translateFunction( translateFunction ) | ||||
|             {} | ||||
|  | ||||
|             virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override { | ||||
|             std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override { | ||||
|                 try { | ||||
|                     if( it == itEnd ) | ||||
|                         throw; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash