unique_ptr w/ custom deleter in header

Jonathan Wakely jwakely.gcc@gmail.com
Sat Jan 19 13:26:00 GMT 2013


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.



More information about the Gcc-help mailing list