@@ -2454,6 +2454,19 @@ namespace json_logic
2454
2454
return compareSeq (deref (lv), deref (rv), std::move (pred));
2455
2455
}
2456
2456
2457
+ // convenience template that only returns a type when the types mismatch
2458
+ template <class U , class V , class ResultType >
2459
+ struct MismatchedTypes
2460
+ {
2461
+ using type = ResultType;
2462
+ };
2463
+
2464
+ template <class T , class ResultType >
2465
+ struct MismatchedTypes <T,T,ResultType>
2466
+ {
2467
+ // using type // triggers SFINAE exclusion
2468
+ };
2469
+
2457
2470
2458
2471
//
2459
2472
// the calc operator implementations
@@ -2466,11 +2479,17 @@ namespace json_logic
2466
2479
{
2467
2480
using EqualityOperator::result_type;
2468
2481
2469
- result_type operator ()(...) const { return false ; } // type mismatch
2482
+ template <class U , class V >
2483
+ auto
2484
+ operator ()(const U&, const V&) const
2485
+ -> typename MismatchedTypes<U,V,result_type>::type // type mismatch
2486
+ {
2487
+ return false ;
2488
+ }
2470
2489
2471
2490
template <class T >
2472
- result_type
2473
- operator ()(const T& lhs, const T& rhs) const
2491
+ auto
2492
+ operator ()(const T& lhs, const T& rhs) const -> result_type
2474
2493
{
2475
2494
return lhs == rhs;
2476
2495
}
@@ -2481,7 +2500,13 @@ namespace json_logic
2481
2500
{
2482
2501
using EqualityOperator::result_type;
2483
2502
2484
- result_type operator ()(...) const { return true ; } // type mismatch
2503
+ template <class U , class V >
2504
+ auto
2505
+ operator ()(const U&, const V&) const
2506
+ -> typename MismatchedTypes<U,V,result_type>::type // type mismatch
2507
+ {
2508
+ return true ;
2509
+ }
2485
2510
2486
2511
template <class T >
2487
2512
result_type
@@ -2496,7 +2521,13 @@ namespace json_logic
2496
2521
{
2497
2522
using StrictEqualityOperator::result_type;
2498
2523
2499
- result_type operator ()(...) const { return false ; } // type mismatch
2524
+ template <class U , class V >
2525
+ auto
2526
+ operator ()(const U&, const V&) const
2527
+ -> typename MismatchedTypes<U,V,result_type>::type // type mismatch
2528
+ {
2529
+ return false ;
2530
+ }
2500
2531
2501
2532
template <class T >
2502
2533
result_type
@@ -2511,7 +2542,13 @@ namespace json_logic
2511
2542
{
2512
2543
using StrictEqualityOperator::result_type;
2513
2544
2514
- result_type operator ()(...) const { return true ; } // type mismatch
2545
+ template <class U , class V >
2546
+ auto
2547
+ operator ()(const U&, const V&) const
2548
+ -> typename MismatchedTypes<U,V,result_type>::type // type mismatch
2549
+ {
2550
+ return true ;
2551
+ }
2515
2552
2516
2553
template <class T >
2517
2554
result_type
0 commit comments