Commit b1c10902 by Jason Merrill

Clean up copy-initialization in overloading code.

        * call.c (build_user_type_conversion_1): Die if we are asked to
        convert to the same or a base type.
        (implicit_conversion): Avoid doing so.  Lose reference binding code.
        (convert_like_real): Treat BASE_CONV and RVALUE_CONV as implicit
        direct-initialization.  Also do direct-init part of copy-init.
        (build_user_type_conversion): Don't provide context to convert_like.
        * cvt.c (ocp_convert): build_user_type_conversion will now provide
        the constructor call for copy-init.

From-SVN: r38159
parent 5e818b93
...@@ -8,9 +8,9 @@ template<typename X> struct auto_ptr { ...@@ -8,9 +8,9 @@ template<typename X> struct auto_ptr {
typedef X element_type; typedef X element_type;
explicit auto_ptr(X* p =0) throw() : px(p) {} explicit auto_ptr(X* p =0) throw() : px(p) {}
auto_ptr(auto_ptr& r) throw() : px(r.release()) {} auto_ptr(auto_ptr& r) throw() : px(r.release()) {} // ERROR - candidate
template<typename Y> template<typename Y>
auto_ptr(auto_ptr<Y>& r) throw() : px(r.release()) {} auto_ptr(auto_ptr<Y>& r) throw() : px(r.release()) {}// ERROR - candidate
auto_ptr& operator=(auto_ptr& r) throw() { auto_ptr& operator=(auto_ptr& r) throw() {
reset(r.release()); reset(r.release());
...@@ -29,7 +29,7 @@ template<typename X> struct auto_ptr { ...@@ -29,7 +29,7 @@ template<typename X> struct auto_ptr {
X* release() throw() { X* p=px; px=0; return p; } X* release() throw() { X* p=px; px=0; return p; }
void reset(X* p=0) throw() { if (px != p) delete px, px = 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) {} auto_ptr(auto_ptr_ref<X> r) throw() : px(r.py) {} // ERROR - candidate
template<typename Y> operator auto_ptr_ref<Y>() throw() { template<typename Y> operator auto_ptr_ref<Y>() throw() {
return auto_ptr_ref<Y>(release()); return auto_ptr_ref<Y>(release());
} }
...@@ -50,5 +50,5 @@ int main() { ...@@ -50,5 +50,5 @@ int main() {
auto_ptr<Derived> y(f()); auto_ptr<Derived> y(f());
x = y; x = y;
g(f()); g(f());
h(f()); h(f()); // ERROR - no usable copy ctor
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment