OSDN Git Service

2008-03-01 Douglas Gregor <doug.gregor@gmail.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / init / init-ref3.C
1 // Origin: Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>
2
3 // { dg-do link }
4
5 template <class T>
6 class Ptr {
7 protected:
8   T * ptr;
9
10 public:
11   
12   Ptr(void) : ptr(0) { }
13   Ptr(T * p) : ptr(p) { }
14   
15   ~Ptr(void) { delete ptr; }
16   
17   operator T & () { return *ptr; }
18 };
19
20 class base {
21 public: 
22   base(void) { }
23   ~base(void) { }
24 };
25
26
27 class foo : public base {
28 private:
29   foo(const foo & rv);
30   
31 public:
32   
33   foo(void) { }
34   ~foo(void) { }
35 };
36
37 void func2(base & b) {
38   // ...
39 }
40
41 int main () {
42   Ptr<foo> f = new foo;
43   /* This should not result in a copy; the result of the conversion
44      operator should be bound directly to the reference argument to
45      `func2'.  */
46   func2(f);
47 }