Boost logo

Boost Users :

Subject: Re: [Boost-users] [shared_ptr] Can the custom deleter be a simple function?
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-11-06 16:17:01


on Sun Nov 06 2011, Robert Jones <robertgbjones-AT-gmail.com> 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?

Two reasons I can think of:

- Function objects can have a templated operator(), so you don't need to
  write a new one for each T in shared_ptr<T>.

- One less level of function call indirection (very minor win)

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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