| 1 |
// PR c++/84231 - overload resolution with cond_expr in a template |
| 2 |
|
| 3 |
// { dg-do compile } |
| 4 |
|
| 5 |
struct format { |
| 6 |
template<typename T> format& operator%(const T&) { return *this; } |
| 7 |
template<typename T> format& operator%(T&) { return *this; } |
| 8 |
}; |
| 9 |
|
| 10 |
format f; |
| 11 |
|
| 12 |
template <typename> |
| 13 |
void function_template(bool b) |
| 14 |
{ |
| 15 |
// Compiles OK with array lvalue: |
| 16 |
f % (b ? "x" : "x"); |
| 17 |
|
| 18 |
// Used to fails with pointer rvalue: |
| 19 |
f % (b ? "" : "x"); |
| 20 |
} |
| 21 |
|
| 22 |
void normal_function(bool b) |
| 23 |
{ |
| 24 |
// Both cases compile OK in non-template function: |
| 25 |
f % (b ? "x" : "x"); |
| 26 |
f % (b ? "" : "x"); |
| 27 |
|
| 28 |
function_template<void>(b); |
| 29 |
} |