[function] Question on semantics of boost::function

Is a boost::function<void (int)> semantically different from a boost::function<void (int &)> or a boost::function<void (const int)>? David -- David Sankel Sankel Software www.sankelsoftware.com 585 617 4748 (Office)

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.
or a boost::function<void (const int)>?
No. boost::function<void(int)> is the same type as boost::function<void(const int)>. In Christ, Steven Watanabe

Allow me to clarify On Fri, Sep 17, 2010 at 6:34 PM, Steven Watanabe <watanabesj@gmail.com> 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
participants (3)
-
Dave Abrahams
-
David Sankel
-
Steven Watanabe