Debian Codegraph @

gcc/testsuite/g++.dg/template/conv2.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 class C
9 {
10 public:
11
12 operator float () {return 2;}
13
14 operator int ()
15 {
16 return 0;
17 }
18
19 template<typename T>
20 operator int ()
21 { return 1;
22 }
23 };
24
25 int main ()
26 {
27 C p;
28 int r;
29
30 r = p.operator int ();
31 if (r)
32 return r;
33 r = static_cast <int> (p);
34
35 if (r)
36 return r + 2;
37
38 return 0;
39 }