fix sfinae on basic_json UDT constructor
Avoid compiler errors when performing SFINAE checks on basic_json and incomplete types.
This commit is contained in:
		
							parent
							
								
									3ac674562f
								
							
						
					
					
						commit
						dcee778c1e
					
				
					 4 changed files with 83 additions and 20 deletions
				
			
		| 
						 | 
				
			
			@ -692,3 +692,22 @@ TEST_CASE("custom serializer that does adl by default", "[udt]")
 | 
			
		|||
    CHECK(me == j.get<udt::person>());
 | 
			
		||||
    CHECK(me == cj.get<udt::person>());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace
 | 
			
		||||
{
 | 
			
		||||
struct incomplete;
 | 
			
		||||
 | 
			
		||||
// std::is_constructible is broken on macOS' libc++
 | 
			
		||||
// use the cppreference implementation
 | 
			
		||||
 | 
			
		||||
template <typename T, typename = void>
 | 
			
		||||
struct is_constructible_patched : std::false_type {};
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
struct is_constructible_patched<T, decltype(void(json(std::declval<T>())))> : std::true_type {};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE("an incomplete type does not trigger a compiler error in non-evaluated context", "[udt]")
 | 
			
		||||
{
 | 
			
		||||
    static_assert(not is_constructible_patched<json, incomplete>::value, "");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue