This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: unique_ptr w/ custom deleter in header


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]