Boost logo

Boost :

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


Marco Costalba wrote:
> On 10/7/07, Miles Bader <miles_at_[hidden]> wrote:
>> "Marco Costalba" <mcostalba_at_[hidden]> writes:
>>> boost::overload<Signatures> f;
>>>
>>> // assign functions in any order
>>> f.add_overload(foo4);
>> Given that the entire point is to hold overloads, isn't "add_overload" a
>> bit redundant? Why not just "add"?
>>
>
> Yes I agree, also because 'overload' is already the name of the struct
> so perhaps add_function() would be better but also functors can be
> added so....perhaps just add() is the best, util now ;-)

"add" looks good, until you "add" something outside the overload set.
You can't. The right word is "assign". But then what's wrong with
operator=?

     f = &foo4;
     f = &foo2;
     f = &foo1;
     f = &foo5;
     f = &foo3;

It has the right semantics and is very idiomatic. This is how
Boost.Function does it. Only in this case, we can have many mappings
instead of just one.

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