Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2007-10-07 19:15:17


Marco wrote:
> On Sun, 07 Oct 2007 10:41:52 +0200, Marco Costalba <mcostalba_at_[hidden]>
> wrote:
>
>> I would think to fix completely the problem reported by Joel we could
>> write instead:
>>
>> boost::is_convertible<F, boost::function<T> >
>>
>> But for unknown reasons this fails! All types of function pointers match!
>>
>> Could someone please be so kind to enlight me?
>>
>> Thanks
>> Marco
>
> Because boost::function has a constructor whose behavior is like this:
>
> template< typename Functor >
> function (Functor const& f)
>
> it skips only integral type through enable_if.
>
> So, except integral, everything is convertible to boost::function even
> apples.
>
> In order to implement signature deduction I exploits a support utility
> used in the implementation of boost::function and a lot of metaprogramming.
> Give a glance to detail::function::get_function_tag in function_base.hpp,
> in order to learn how to discern between different kind of functors.

Tobias (Schwinger) has this excellent library for dealing with function
detection: Boost.function_types. It's in SVN now...

However, I do not think this will help at all. Ok, so, say we have
a polymorphic function (object) called pf. Then we have an overload
set with 5 signatures, ov. pf can deal with 3 of them (say the first
three). Now, how do you automatically "assign" pf to the first
three overloads? You can't. There's no way to detect the signature
of a template function (the operator()):

Here's what I mean. Using the "add" syntax:

     ov.add(pf); // which one? duh!

Regards,

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

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