Boost logo

Boost :

From: Marco Costalba (mcostalba_at_[hidden])
Date: 2008-03-06 05:49:20


On Wed, Mar 5, 2008 at 10:40 PM, vicente.botet <vicente.botet_at_[hidden]> wrote:
>
> I have take a lock to the code. Could you tell us if there is a deep raison
> to not use boost::function, boost::enable_if, boost::mpl::list ...?
>

Only to be self contained, this is not intended to be library, it's
more of an example and a concept proposal thing, in case there is
interest I can trasnform it in a stable and reliable thing using the
above mentioned facilities.

> What happens if we forget to initialize one of the signatures? crash ?

Yes. Why it shouldn't ;-)

IOW if you "forget" to initialize a function it's a bug. A crash is a
very good diagnostic for such a bug.

> What can you do to improbe this aspect.
>
> Do you think that is possible to have a version ensuring a default function
> for each signature? Somting like
>
> overload_ns::overload <
> signatures<int()
> , int(char),
> , double(int, char),
> , char(string),
> , string(string, string, string)
> >,
> default_functions<foo1, &foo2, foo3, &foo4, foo5_ptr>
> > f;
>

A possible better way could be to set the functions directly in the constructor:

  overload_ns::overload <
       signatures<int()
           , int(char),
           , double(int, char),
           , char(string),
           , string(string, string, string)
> f(foo1, &foo2, foo3, &foo4, foo5_ptr);

BTW in my opinion default functions to avoid a crash when user
"forgets" to initialize properly it means to replace a simply
discoverable bug with a much more subtle one. This is just my opinion.

Thanks
Marco


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