| 1 |
// Origin: Peter Schmid <[email protected]> |
| 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 |
} |