forked from catchorg/Catch2
		
	Fix ambiguity in stringification
Happening when using clang and templated operators, clang cannot decide between the operator provided by ReusableStringStream and the one provided by the value value as both are templates. This is easily solved by calling the operator<< through the member syntax. Fixes #1285
This commit is contained in:
		
				
					committed by
					
						
						Martin Hořeňovský
					
				
			
			
				
	
			
			
			
						parent
						
							021fcee636
						
					
				
				
					commit
					7be8a41adf
				
			@@ -20,6 +20,7 @@ struct has_operator { };
 | 
			
		||||
struct has_maker {};
 | 
			
		||||
struct has_maker_and_operator {};
 | 
			
		||||
struct has_neither {};
 | 
			
		||||
struct has_template_operator {};
 | 
			
		||||
 | 
			
		||||
std::ostream& operator<<(std::ostream& os, const has_operator&) {
 | 
			
		||||
    os << "operator<<( has_operator )";
 | 
			
		||||
@@ -31,6 +32,12 @@ std::ostream& operator<<(std::ostream& os, const has_maker_and_operator&) {
 | 
			
		||||
    return os;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename StreamT>
 | 
			
		||||
StreamT& operator<<(StreamT& os, const has_template_operator&) {
 | 
			
		||||
    os << "operator<<( has_template_operator )";
 | 
			
		||||
    return os;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace Catch {
 | 
			
		||||
    template<>
 | 
			
		||||
    struct StringMaker<has_maker> {
 | 
			
		||||
@@ -69,6 +76,12 @@ TEST_CASE("stringify( has_neither )", "[toString]") {
 | 
			
		||||
    REQUIRE( ::Catch::Detail::stringify(item) == "{ !!! }" );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Call the templated operator
 | 
			
		||||
TEST_CASE( "stringify( has_template_operator )", "[toString]" ) {
 | 
			
		||||
    has_template_operator item;
 | 
			
		||||
    REQUIRE( ::Catch::Detail::stringify( item ) == "operator<<( has_template_operator )" );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Vectors...
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user