2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / init / init-ref3.C
blobaaf04cff6848d2ac6c8d8880dac322b5ce53ac49
1 // Origin: Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>
3 // { dg-do link }
5 template <class T>
6 class Ptr {
7 protected:
8   T * ptr;
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; }
20 class base {
21 public: 
22   base(void) { }
23   ~base(void) { }
27 class foo : public base {
28 private:
29   foo(const foo & rv);
30   
31 public:
32   
33   foo(void) { }
34   ~foo(void) { }
37 void func2(base & b) {
38   // ...
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);