gcc/testsuite/g++.dg/template/fntype1.C
raw| 1 | bool f(int i) { return i != 5; } |
| 2 | |
| 3 | template <class X, class P = bool(X)> |
| 4 | struct Traits |
| 5 | { |
| 6 | typedef P type; |
| 7 | }; |
| 8 | |
| 9 | template <class X, class P = typename Traits<X>::type> |
| 10 | struct S |
| 11 | { |
| 12 | const P& p_; |
| 13 | S( const P& p ) : p_(p) {} // const reference |
| 14 | }; |
| 15 | |
| 16 | template <class X> |
| 17 | S<X> make_s(const typename Traits<X>::type & p) // const reference |
| 18 | { |
| 19 | return S<X>(p); // << HERE |
| 20 | } |
| 21 | |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | make_s<int>(f); |
| 26 | } |