Topic: Is this code correct?
Author: "Andrei Alexandrescu" <andrewalex@hotmail.com>
Date: 16 Oct 02 18:28:29 GMT Raw View
#include <memory>
class A {};
void Fun(const std::auto_ptr<A>&) {}
Fun(std::auto_ptr<A>(new A));
Thanks!
Andrei
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: hyrosen@mail.com (Hyman Rosen)
Date: Wed, 16 Oct 2002 20:21:08 +0000 (UTC) Raw View
Andrei Alexandrescu wrote:
> #include <memory>
> class A {};
> void Fun(const std::auto_ptr<A>&) {}
> Fun(std::auto_ptr<A>(new A));
No, it's not legal. The argument passed to Fun
is not an lvalue. There is no conversion function
to turn it into one, so we fail 8.5.3/5/1/2, and
there is no copy constructor to make a temporary,
so we fail 8.5.3/5/2/2.
On-line Comeau diagnoses this.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]