Boost logo

Boost Users :

Subject: Re: [Boost-users] [shared_ptr] Can the custom deleter be a simple function?
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2011-11-07 03:11:20


On Sun, Nov 6, 2011 at 8:52 PM, Robert Jones <robertgbjones_at_[hidden]>wrote:

> The shared_ptr docs suggest that a smart pointer employing a null deleter
> can be
> implemented using a functor. Why prefer a functor to a function?
>
>
Thanks Gents - The phrasing of my question was hopelessly lax: I appreciate
in the
general case why one might choose to use a functor rather than a function
as a callable
object, what I didn't grasp (and there may be nothing to grasp), was why
this (from the
shared_ptr docs)

struct null_deleter
{
    void operator()(void const *) const
    {
    }
};

Is implemented as a functor rather than a function. It's already void*, so
I think no considerations
of static polymorphism or templating, and no state, but maybe there's
something else I've not
thought of?

Thx

- Rob.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net