Boost logo

Boost :

Subject: Re: [boost] [convert] no-throw and fallback feature
From: Vicente BOTET (vicente.botet_at_[hidden])
Date: 2011-05-10 13:56:12


> Message du 10/05/11 19:50
> De : "Stewart, Robert"
> A : "'boost_at_[hidden]'"
> Copie à :
> Objet : Re: [boost] [convert] no-throw and fallback feature
>
> Vicente BOTET wrote:
> > De : "Stewart, Robert"
> >
> > > It appears that we're suggesting that opt_tie() be
> > > overloaded:
> > >
> > > int i;
> > > bool b;
> > > opt_tie(i, b) = convert_to>(s);
> > > if (!b)
> > > {
> > > i = fallback;
> > > std::cerr << "using fallback\n";
> > > }
> > >
> > > and
> > >
> > > i = fallback;
> > > opt_tie(i) = convert_to>(s);
> >
> > No. I don't think the overload with the boolean parameter is
> > really useful and it is a little bit confusing to have both.
>
> I don't think having both would be confusing.
>
> Without the bool overload, there's try_convert_to() or using optional overtly:
>
> optional const o(convert_to>(s));
> if (o)
> {
> // use o.get()
> }
> else
> {
> // use a fallback value
> std::cerr << "using fallback\n";
> }
>
> The opt_tie() bool overload is a bit simpler, don't you think?
>
> For general use with optional, I think the opt_tie() overload might be useful.
>
Sorry Robert. You lost me.
Are you using the word overload instead of conversion?

Form which overloads of opt_tie are you talking of?
opt_tie(T)
and
opt_tie(T,bool)?

Vicente


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