blob: ecfa4de18f9fdfe58c1d54b506b2dc6ad3df8a12 (
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
48
49
50
51
52
53
54
55
56
|
// { dg-do assemble }
template <typename Y> struct auto_ptr_ref {
Y* py;
auto_ptr_ref(Y* p) : py(p) {}
};
template<typename X> struct auto_ptr {
X* px;
public:
typedef X element_type;
explicit auto_ptr(X* p =0) throw() : px(p) {}
auto_ptr(auto_ptr& r) throw() : px(r.release()) {} // { dg-message "note" } candidate
template<typename Y>
auto_ptr(auto_ptr<Y>& r) throw() : px(r.release()) {}// { dg-message "note" } candidate
auto_ptr& operator=(auto_ptr& r) throw() {
reset(r.release());
return *this;
}
template<typename Y> auto_ptr& operator=(auto_ptr<Y>& r) throw() {
reset(r.release());
return *this;
}
~auto_ptr() { delete px; }
X& operator*() const throw() { return *px; }
X* operator->() const throw() { return px; }
X* get() const throw() { return px; }
X* release() throw() { X* p=px; px=0; return p; }
void reset(X* p=0) throw() { if (px != p) delete px, px = p; }
auto_ptr(auto_ptr_ref<X> r) throw() : px(r.py) {} // { dg-message "note" }
template<typename Y> operator auto_ptr_ref<Y>() throw() {
return auto_ptr_ref<Y>(release());
}
template<typename Y> operator auto_ptr<Y>() throw() {
return auto_ptr<Y>(release());
}
};
struct Base { Base() {} virtual ~Base() {} };
struct Derived : Base { Derived() {} };
auto_ptr<Derived> f() { auto_ptr<Derived> null(0); return null; }
void g(auto_ptr<Derived>) { }
void h(auto_ptr<Base>) { } // { dg-error "initializing" }
int main() {
auto_ptr<Base> x(f());
auto_ptr<Derived> y(f());
x = y;
g(f());
h(f()); // { dg-error "match" "match" } no usable copy ctor
// { dg-message "candidate" "candidate note" { target *-*-* } 54 }
}
|