Debian Codegraph @

gcc/testsuite/g++.dg/template/conv3.C

raw
1 // { dg-do run }
2
3 // Copyright (C) 2001 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 29 Dec 2001 <[email protected]>
5
6 // PR 4361. Template conversion operators were not overloaded.
7
8 template <typename T> struct C
9 {
10 operator T ()
11 {
12 return 0;
13 }
14 template <typename T2> operator T2 ()
15 {
16 return 1;
17 }
18 int Foo ()
19 {
20 return operator T ();
21 }
22 template <typename T2> int Baz ()
23 {
24 return static_cast <int> (operator T2 ());
25 }
26 };
27
28 int main ()
29 {
30 int r;
31 C<int> c;
32
33 r = c.Foo ();
34 if (r)
35 return 1;
36 r = c.Baz<int> ();
37 if (r)
38 return 2;
39 r = c.Baz<float> ();
40 if (!r)
41 return 3;
42 return 0;
43 }