diff options
| author | Phil Nash | 2015-05-19 18:37:58 +0100 |
|---|---|---|
| committer | Phil Nash | 2015-05-19 22:31:57 +0100 |
| commit | e86daf8bdda2ee32354f20a48c4e9a78a6429617 (patch) | |
| tree | 0c21de4c0fcac5b43f662852010aa8bb030a2536 /include | |
| parent | bfa3f863d64b1eff3082c781c026a45a7c6938a3 (diff) | |
| download | catch3-e86daf8bdda2ee32354f20a48c4e9a78a6429617.tar.gz | |
Reorganised C+11 feature detection a bit
and added CATCH_CONFIG_CPP11_NULLPTR for VS2015
Diffstat (limited to 'include')
| -rw-r--r-- | include/external/clara.h | 2 | ||||
| -rw-r--r-- | include/internal/catch_assertionresult.h | 2 | ||||
| -rw-r--r-- | include/internal/catch_common.h | 4 | ||||
| -rw-r--r-- | include/internal/catch_compiler_capabilities.h | 63 | ||||
| -rw-r--r-- | include/internal/catch_expression_lhs.hpp | 4 | ||||
| -rw-r--r-- | include/internal/catch_interfaces_reporter.h | 10 | ||||
| -rw-r--r-- | include/internal/catch_tostring.h | 13 | ||||
| -rw-r--r-- | include/internal/catch_xmlwriter.hpp | 21 |
8 files changed, 75 insertions, 44 deletions
diff --git a/include/external/clara.h b/include/external/clara.h index ce2ef2ec..bc162806 100644 --- a/include/external/clara.h +++ b/include/external/clara.h @@ -251,7 +251,7 @@ namespace Clara { template<typename ConfigT> struct IArgFunction { virtual ~IArgFunction() {} -# ifdef CATCH_CPP11_OR_GREATER +# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS IArgFunction() = default; IArgFunction( IArgFunction const& ) = default; # endif diff --git a/include/internal/catch_assertionresult.h b/include/internal/catch_assertionresult.h index adcc0215..99b3a7c3 100644 --- a/include/internal/catch_assertionresult.h +++ b/include/internal/catch_assertionresult.h @@ -41,7 +41,7 @@ namespace Catch { AssertionResult(); AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); ~AssertionResult(); -# ifdef CATCH_CPP11_OR_GREATER +# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS AssertionResult( AssertionResult const& ) = default; AssertionResult( AssertionResult && ) = default; AssertionResult& operator = ( AssertionResult const& ) = default; diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h index aadb0d34..9f07e47c 100644 --- a/include/internal/catch_common.h +++ b/include/internal/catch_common.h @@ -24,7 +24,7 @@ namespace Catch { class NonCopyable { -#ifdef CATCH_CPP11_OR_GREATER +#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS NonCopyable( NonCopyable const& ) = delete; NonCopyable( NonCopyable && ) = delete; NonCopyable& operator = ( NonCopyable const& ) = delete; @@ -87,7 +87,7 @@ namespace Catch { SourceLineInfo(); SourceLineInfo( char const* _file, std::size_t _line ); SourceLineInfo( SourceLineInfo const& other ); -# ifdef CATCH_CPP11_OR_GREATER +# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS SourceLineInfo( SourceLineInfo && ) = default; SourceLineInfo& operator = ( SourceLineInfo const& ) = default; SourceLineInfo& operator = ( SourceLineInfo && ) = default; diff --git a/include/internal/catch_compiler_capabilities.h b/include/internal/catch_compiler_capabilities.h index 5ed98c2f..983b7fa3 100644 --- a/include/internal/catch_compiler_capabilities.h +++ b/include/internal/catch_compiler_capabilities.h @@ -8,7 +8,22 @@ #ifndef TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED #define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED -// Much of the following code is based on Boost (1.53) +// Detect a number of compiler features - mostly C++11/14 conformance - by compiler +// The following features are defined: +// +// CATCH_CONFIG_CPP11_NULLPTR : is nullptr supported? +// CATCH_CONFIG_CPP11_NOEXCEPT : is noexcept supported? +// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods +// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported? +// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported + +// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported? + +// CATCH_CONFIG_SFINAE : is basic (C++03) SFINAE supported? +// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported? + + +// A lot of this code is based on Boost (1.53) #ifdef __clang__ @@ -88,6 +103,13 @@ //#define CATCH_CONFIG_SFINAE // Not confirmed #endif +#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015)) +#define CATCH_CONFIG_CPP11_NOEXCEPT +#define CATCH_CONFIG_CPP11_GENERATED_METHODS +#define CATCH_CONFIG_CPP11_NULLPTR +//#define CATCH_CONFIG_SFINAE // Don't use, for now +#endif + #endif // _MSC_VER // Use variadic macros if the compiler supports them @@ -105,13 +127,40 @@ //////////////////////////////////////////////////////////////////////////////// // C++ language feature support -// detect language version: -#if (__cplusplus == 201103L) -# define CATCH_CPP11 -# define CATCH_CPP11_OR_GREATER -#elif (__cplusplus >= 201103L) +// catch all support for C++11 +#if (__cplusplus >= 201103L) + # define CATCH_CPP11_OR_GREATER -#endif + +# ifndef CATCH_CONFIG_CPP11_NULLPTR +# define CATCH_CONFIG_CPP11_NULLPTR +# endif + +# ifndef CATCH_CONFIG_CPP11_NOEXCEPT +# define CATCH_CONFIG_CPP11_NOEXCEPT +# endif + +# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS +# define CATCH_CONFIG_CPP11_GENERATED_METHODS +# endif + +# ifndef CATCH_CONFIG_CPP11_IS_ENUM +# define CATCH_CONFIG_CPP11_IS_ENUM +# endif + +# ifndef CATCH_CONFIG_CPP11_TUPLE +# define CATCH_CONFIG_CPP11_TUPLE +# endif + +# ifndef CATCH_CONFIG_SFINAE +//# define CATCH_CONFIG_SFINAE // Don't use, for now +# endif + +# ifndef CATCH_CONFIG_VARIADIC_MACROS +# define CATCH_CONFIG_VARIADIC_MACROS +# endif + +#endif // __cplusplus >= 201103L // noexcept support: #if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) diff --git a/include/internal/catch_expression_lhs.hpp b/include/internal/catch_expression_lhs.hpp index f9876238..51b803e5 100644 --- a/include/internal/catch_expression_lhs.hpp +++ b/include/internal/catch_expression_lhs.hpp @@ -19,13 +19,13 @@ namespace Catch { template<typename T> class ExpressionLhs { ExpressionLhs& operator = ( ExpressionLhs const& ); -# ifdef CATCH_CPP11_OR_GREATER +# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS ExpressionLhs& operator = ( ExpressionLhs && ) = delete; # endif public: ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {} -# ifdef CATCH_CPP11_OR_GREATER +# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS ExpressionLhs( ExpressionLhs const& ) = default; ExpressionLhs( ExpressionLhs && ) = default; # endif diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 5296177a..ff893038 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -101,7 +101,7 @@ namespace Catch } virtual ~AssertionStats(); -# ifdef CATCH_CPP11_OR_GREATER +# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS AssertionStats( AssertionStats const& ) = default; AssertionStats( AssertionStats && ) = default; AssertionStats& operator = ( AssertionStats const& ) = default; @@ -124,7 +124,7 @@ namespace Catch missingAssertions( _missingAssertions ) {} virtual ~SectionStats(); -# ifdef CATCH_CPP11_OR_GREATER +# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS SectionStats( SectionStats const& ) = default; SectionStats( SectionStats && ) = default; SectionStats& operator = ( SectionStats const& ) = default; @@ -151,7 +151,7 @@ namespace Catch {} virtual ~TestCaseStats(); -# ifdef CATCH_CPP11_OR_GREATER +# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS TestCaseStats( TestCaseStats const& ) = default; TestCaseStats( TestCaseStats && ) = default; TestCaseStats& operator = ( TestCaseStats const& ) = default; @@ -179,7 +179,7 @@ namespace Catch {} virtual ~TestGroupStats(); -# ifdef CATCH_CPP11_OR_GREATER +# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS TestGroupStats( TestGroupStats const& ) = default; TestGroupStats( TestGroupStats && ) = default; TestGroupStats& operator = ( TestGroupStats const& ) = default; @@ -201,7 +201,7 @@ namespace Catch {} virtual ~TestRunStats(); -# ifndef CATCH_CPP11_OR_GREATER +# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS TestRunStats( TestRunStats const& _other ) : runInfo( _other.runInfo ), totals( _other.totals ), diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index 8e6e1581..2043f99f 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -21,8 +21,11 @@ #include "catch_objc_arc.hpp" #endif -#ifdef CATCH_CPP11_OR_GREATER +#ifdef CATCH_CONFIG_CPP11_TUPLE #include <tuple> +#endif + +#ifdef CATCH_CONFIG_CPP11_IS_ENUM #include <type_traits> #endif @@ -105,7 +108,7 @@ namespace Detail { #endif -#if defined(CATCH_CPP11_OR_GREATER) +#if defined(CATCH_CONFIG_CPP11_IS_ENUM) template<typename T, bool IsEnum = std::is_enum<T>::value > @@ -127,7 +130,7 @@ namespace Detail { #endif template<bool C> struct StringMakerBase { -#if defined(CATCH_CPP11_OR_GREATER) +#if defined(CATCH_CONFIG_CPP11_IS_ENUM) template<typename T> static std::string convert( T const& v ) { @@ -201,7 +204,7 @@ std::string toString( std::vector<T,Allocator> const& v ) { } -#ifdef CATCH_CPP11_OR_GREATER +#ifdef CATCH_CONFIG_CPP11_TUPLE // toString for tuples namespace TupleDetail { @@ -241,7 +244,7 @@ struct StringMaker<std::tuple<Types...>> { return os.str(); } }; -#endif +#endif // CATCH_CONFIG_CPP11_TUPLE namespace Detail { template<typename T> diff --git a/include/internal/catch_xmlwriter.hpp b/include/internal/catch_xmlwriter.hpp index d47c2b4d..553c5a79 100644 --- a/include/internal/catch_xmlwriter.hpp +++ b/include/internal/catch_xmlwriter.hpp @@ -67,27 +67,6 @@ namespace Catch { endElement(); } -//# ifndef CATCH_CPP11_OR_GREATER -// XmlWriter& operator = ( XmlWriter const& other ) { -// XmlWriter temp( other ); -// swap( temp ); -// return *this; -// } -//# else -// XmlWriter( XmlWriter const& ) = default; -// XmlWriter( XmlWriter && ) = default; -// XmlWriter& operator = ( XmlWriter const& ) = default; -// XmlWriter& operator = ( XmlWriter && ) = default; -//# endif -// -// void swap( XmlWriter& other ) { -// std::swap( m_tagIsOpen, other.m_tagIsOpen ); -// std::swap( m_needsNewline, other.m_needsNewline ); -// std::swap( m_tags, other.m_tags ); -// std::swap( m_indent, other.m_indent ); -// std::swap( m_os, other.m_os ); -// } - XmlWriter& startElement( std::string const& name ) { ensureTagClosed(); newlineIfNecessary(); |