|
Boost : |
From: Marco Costalba (mcostalba_at_[hidden])
Date: 2008-05-10 13:39:07
On Sat, May 10, 2008 at 6:08 PM, Giovanni Piero Deretta
<gpderetta_at_[hidden]> wrote:
>
> Well my idea was that an unconstrained template function object would be
> bound to all internal boost::functions
You mean something like this
template<int> struct end_seq_tag { typedef int type; };
template<> struct end_seq_tag<-1> { typedef char type; };
template<int n, typename T>
void assign(T const& t, int*)
{
/* first convert to boost::function then add */
*this += boost::function< at_c<n, Signatures>::type >(t);
assign<n - 1>(t, (end_seq_tag<n - 1>::type*)0); /* iterate */
}
template<int n, typename T>
void assign(T const&, char*) {} /* end condition here */
template<typename T>
function& operator=(T const& t)
{
assign<signatures_size - 1>(t, (end_seq_tag<signatures_size - 1>::type*)0);
return *this;
}
I have written fast, probably there is a better way, but just to show
the idea. Is this what you mean ?
> I think that in your case, using
> operator= is confusing because you are not really reassigning the MSF but
> just adding an overload. What if operator= tries to bind all signatures at
> once (and thus allows for boost::function like adaptability) and operator+=
> (or an explicit add member function) is strict and allows to replace a single
> overload?
operator+= is a nice idea, like an explicit set() or add() method. I
have been stick to operator=() just to follow boost::function API, but
I agree in case of MSF this could be confusing...
>>
>> Where boost.function naturally models a function, multi-signature
>> boost::function naturally models an overload set
>
> Actually it is a bit more, because you can have different state for
> each overload. I would need something in the middle:
> a single polymorphic closure which can be accessed dynamically
> with multiple objects.
>
Sorry but the above sentence does not parse for me. I have to think
again on what you meant, sorry, but could you better explain what you
mean ? It's my fault to be dumb ;-)
Thanks
Marco
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk