Boost logo

Boost :

Subject: [boost] [proto] _value doesn't enforce zero arity
From: troy d. straszheim (troy_at_[hidden])
Date: 2009-04-06 20:37:00


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.

Here as usual is an attempt at a patch, to see if I'm learning anything:

BOOST_MPL_ASSERT_RELATION(
   remove_reference<Expr>::type::proto_arity_c,
   ==,
   0L);

in the body of struct _value in transform/args.hpp. How'd I do?

-t


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