gcc/testsuite/g++.dg/cpp1y/var-templ37.C
raw| 1 | // PR c++/65195 |
| 2 | // { dg-do compile { target c++14 } } |
| 3 | |
| 4 | template<typename T> |
| 5 | T constant {}; |
| 6 | |
| 7 | template<typename T> |
| 8 | struct foo { |
| 9 | int operator()() const |
| 10 | { return 3; } |
| 11 | }; |
| 12 | |
| 13 | template<typename T> |
| 14 | auto& f = constant<foo<T>>; |
| 15 | |
| 16 | int main() |
| 17 | { |
| 18 | // fine |
| 19 | auto& ref = f<int>; ref(); |
| 20 | |
| 21 | // error: f<int> cannot be used as a function |
| 22 | f<int>(); |
| 23 | } |