A bug. It's fixed now on the trunk and release branches. Thanks.
Thank you, Eric. That works, but now proto::lazy isn't working with
proto::fold.
Below is a program you posted to boost.devel on 3/29/2008, updated with
s/bind/lazy/ and s/_arg/_child/. It's giving me the following syntax error.
Any idea what's wrong?
Thanks,
Dave Jenkins
error C2664: 'Accumulator::Accumulator(const
Accumulator &)' : cannot convert parameter 1 from
'Accumulator' to 'const Accumulator &'
c:\boost\boost\proto\transform\call.hpp 156
#include <iostream>
#include
#include
#include
#include
#include
#include
#include
namespace mpl = boost::mpl;
namespace proto = boost::proto;
template<typename IsValid = mpl::true_, typename Value = void>
struct Accumulator
: IsValid
{
template<typename Value2>
struct validate
: mpl::and_<
IsValid
, mpl::or_<
boost::is_void<Value>
, boost::is_same
>
>
{};
template<typename Sig>
struct result;
template
struct result
{
typedef Accumulator type;
};
template<typename Value2>
typename result::type
operator ()(Value2 const &) const
{
return typename result::type();
}
};
struct SameTerminals
: proto::or_<
proto::when<
proto::terminalproto::_
// treat the current state as a callable
// object and pass it the value of the terminal.
, proto::lazyproto::_state(proto::_child)
>
, proto::otherwise<
proto::fold
>
>
{};
int main()
{
int dummy = 0;
proto::terminal<int>::type i = {0}, j = {1}, k = {2};
proto::terminal<short>::type s = {42};
BOOST_ASSERT( SameTerminals()(i+j*k, Accumulator<>(), dummy) );
BOOST_ASSERT(!SameTerminals()(i+s*k, Accumulator<>(), dummy) );
}