Topic: auto_ptr of incomplete type not allowed?


Author: "Leigh Johnston" <leigh@i42.co.uk>
Date: Tue, 2 Feb 2010 17:44:08 CST
Raw View
Hi,

N3000 states that an incomplete type is allowed for shared_ptr and
unique_ptr but it doesn't say the same for auto_ptr.  Is this omission a
mistake or deliberate?

An incomplete type auto_ptr member variable should be allowed as long as
parent class destructor is not declared inline.  This is useful when
implemented pimpl idiom:

struct opaque_type;

struct foo
{
 ~foo(); // dtor defined elsewhere
 std::auto_ptr<opaque_type> pimpl;
};

/Leigh

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use
mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: =?ISO-8859-1?Q?Pedro_Lamar=E3o?= <pedro.lamarao@gmail.com>
Date: Wed, 3 Feb 2010 11:52:47 CST
Raw View
On 2 fev, 21:44, "Leigh Johnston" <le...@i42.co.uk> wrote:

> N3000 states that an incomplete type is allowed for shared_ptr and
> unique_ptr but it doesn't say the same for auto_ptr.  Is this omission a
> mistake or deliberate?
>
> An incomplete type auto_ptr member variable should be allowed as long as
> parent class destructor is not declared inline.  This is useful when
> implemented pimpl idiom:

auto_ptr is specified like that in C++03.

Why improve auto_ptr when we have unique_ptr and shared_ptr?

All we need from auto_ptr is backwards compatibility.

--
  P.


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]