Fixed std::distance compile error with Oracle Solaris Studio 12.1

Building Catch with Oracle Solaris Studio 12.1 generates an error when calling
std::distance due to the toolchains non-compliant STL implementation.  This
implementation returns its result via an output parameter rather than a return
value.
This commit is contained in:
Andrew Foster 2016-10-10 11:34:19 +01:00
parent 87803cdd2d
commit 1f97d4d318
2 changed files with 15 additions and 0 deletions

View File

@ -119,6 +119,16 @@
#endif // _MSC_VER #endif // _MSC_VER
////////////////////////////////////////////////////////////////////////////////
// Oracle Solaris Studio
#ifdef __SUNPRO_CC
# if __SUNPRO_CC == 0x5100 // Oracle Solaris Studio version 12.1
# define CATCH_INTERNAL_SUNPRO_CC_NON_COMPLIANT_STL
# endif
#endif // __SUNPRO_CC
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Use variadic macros if the compiler supports them // Use variadic macros if the compiler supports them

View File

@ -218,7 +218,12 @@ namespace Catch {
// using messages.end() directly yields compilation error: // using messages.end() directly yields compilation error:
std::vector<MessageInfo>::const_iterator itEnd = messages.end(); std::vector<MessageInfo>::const_iterator itEnd = messages.end();
# ifdef CATCH_INTERNAL_SUNPRO_CC_NON_COMPLIANT_STL
std::size_t N;
std::distance( itMessage, itEnd, N );
# else
const std::size_t N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) ); const std::size_t N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) );
# endif // CATCH_INTERNAL_SUNPRO_CC_NON_COMPLIANT_STL
{ {
Colour colourGuard( colour ); Colour colourGuard( colour );