aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/init/init-ref3.C
blob: e858fd74d317e58ab36867077b5593aa7f2ad62d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Origin: Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>

// { dg-do link }

template <class T>
class Ptr {
protected:
  T * ptr;

public:
  
  Ptr(void) : ptr(0) { }
  Ptr(T * p) : ptr(p) { }
  
  ~Ptr(void) { delete ptr; }
  
  operator T & () { return *ptr; }
};

class base {
public: 
  base(void) { }
  ~base(void) { }
};


class foo : public base {
private:
  foo(const foo & rv);
  
public:
  
  foo(void) { }
  ~foo(void) { }
};

void func2(base & b) {
  // ...
}

int main () {
  Ptr<foo> f = new foo;
  /* This should not result in a copy; the result of the conversion
     operator should be bound directly to the reference argument to
     `func2'.  */
  func2(f);
}