This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: unique_ptr w/ custom deleter in header
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Nick <nospam at codesniffer dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 19 Jan 2013 13:24:24 +0000
- Subject: Re: unique_ptr w/ custom deleter in header
- References: <1358565730.11707.24.camel@nimble.325Bayport>
On Jan 19, 2013 3:22 AM, "Nick"? wrote:
>
> When I use a std::unique_ptr w/ a custom deleter via an inline lambda in
> a non-template function implemented inline in a header file, I get a
> linker error.
The error you're getting is a known bug with lambdas, you can find
multiple issues like it in bugzilla.
> Note that the specifics of this example are only for demonstration
> purposes--I'm not actually trying to use a custom deleter to perform
> what the default implementation does.
It's good that it's only for demonstration because your deleters have
undefined behaviour, they mix the array form of 'new' with the
non-array 'delete'.
Usually the unique_ptr<T[]> specialization should be used for arrays.