mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Add opt-in c++11 stream insertable check. (#877)
* Add opt-in c++11 stream insertable check. To opt-in, define CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK. Opt-in fixes #872 and should fix #757 as well.
This commit is contained in:

committed by
Martin Hořeňovský

parent
0354d50278
commit
94425ad59b
@@ -72,6 +72,7 @@ namespace Detail {
|
||||
|
||||
extern const std::string unprintableString;
|
||||
|
||||
#if !defined(CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK)
|
||||
struct BorgType {
|
||||
template<typename T> BorgType( T const& );
|
||||
};
|
||||
@@ -90,6 +91,20 @@ namespace Detail {
|
||||
static T const&t;
|
||||
enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
|
||||
};
|
||||
#else
|
||||
template<typename T>
|
||||
class IsStreamInsertable {
|
||||
template<typename SS, typename TT>
|
||||
static auto test(int)
|
||||
-> decltype( std::declval<SS&>() << std::declval<TT>(), std::true_type() );
|
||||
|
||||
template<typename, typename>
|
||||
static auto test(...) -> std::false_type;
|
||||
|
||||
public:
|
||||
static const bool value = decltype(test<std::ostream,const T&>(0))::value;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_CONFIG_CPP11_IS_ENUM)
|
||||
template<typename T,
|
||||
|
Reference in New Issue
Block a user