Boost logo

Boost :

Subject: Re: [boost] [proto] _value doesn't enforce zero arity
From: Eric Niebler (eric_at_[hidden])
Date: 2009-04-06 23:49:33


troy d. straszheim wrote:
> I see some funny behavior when misusing _value:
>
> #include <boost/proto/proto.hpp>
>
> namespace bp = boost::proto;
>
> int main(int, char**)
> {
> bp::terminal<int>::type t = {0};
>
> bp::terminal<int>::type hmm = bp::value(t * 2);
> bp::terminal<int>::type uhm = bp::_value()(t * 2);
>
> bp::terminal<const int&>::type hrm = bp::value(2 * t);
> bp::terminal<const int&>::type feh = bp::_value()(2 * t);
> }
>
> Which does compile.. but the docs say that _value requires an
> expression of zero arity.
<snip>

Yep, it compiles, and yep, it violates the preconditions. I choose not
to enforce the preconditions because doing so would cause extra template
instantiations and lengthen compile times. As long as valid programs
compile and do the right thing, I'm happy.

-- 
Eric Niebler
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