Boost logo

Boost :

Subject: Re: [boost] [guidelines] why template errors suck
From: David Abrahams (dave_at_[hidden])
Date: 2010-09-28 14:17:18


At Tue, 28 Sep 2010 13:29:15 -0400 (EDT),
Jeremiah Willcock wrote:
>
> On Tue, 28 Sep 2010, David Abrahams wrote:
>
> > At Tue, 28 Sep 2010 11:21:55 -0400 (EDT),
> > Jeremiah Willcock wrote:
> >>
> >>> is_convertible<decltype(f != l), bool>::value
> >>> is_convertible<decltype(p(*f)), bool>::value
> >>
> >> These can be written as "normal" valid expressions:
> >>
> >> bool(f != l)
> >> bool(p(*f))
> >
> > Isn't bool(x) equivalent to (bool)x? I think that's valid code for
> > any x.
>
> Yes. My comment there was just that you did not need decltype and
> is_convertible to write those two constraints -- a standard cast would
> work.

I don't think there's any standard cast that can check implicit
convertibility without also allowing other undesired things. For
example, static_cast<Derived*>(base_ptr) works, but Base* can't be
converted to Derived*.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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