Boost logo

Boost :

Subject: Re: [boost] [function] Question on semantics of boost::function
From: Dave Abrahams (dave_at_[hidden])
Date: 2010-09-18 00:17:33


Allow me to clarify

On Fri, Sep 17, 2010 at 6:34 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> AMDG
>
> David Sankel wrote:
>>
>> Is a boost::function<void (int)> semantically different from
>> a boost::function<void (int &)>
>
> Yes.  The signature of a boost::function behaves
> exactly the same way as the signature of a normal
> function.

The difference being, for example, that if you wrap a void(*)(int&) in
the 2nd one, it will receive a reference to the actual argument.

>> or a boost::function<void (const int)>?
>>
>
> No.  boost::function<void(int)> is the same type
> as boost::function<void(const int)>.

because the type void (int) is actually equivalent to the type
void(const int). Constness of parameters is discarded except in the
implementation of a function.

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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk