Boost logo

Boost Users :

Subject: Re: [Boost-users] [Proto] Nested Types in Transforms
From: Eric Niebler (eric_at_[hidden])
Date: 2011-02-15 19:52:57


On 2/16/2011 7:04 AM, Hossein Haeri wrote:
> Dear all,
>
> In my namespace arity_caller, I have a struct CanBeCalled<> such that CanBeCalled<T, mpl::int_<n> >::type is an mpl::bool_<> representing whether T can be called with n doubles. I also have the following grammar (in a file called 'EmtnGram.hpp') in which I am trying to employ this CanBeCalled<>::type:
>
> struct EmtnShiftFObjGram:
> boost::proto::and_
> <
> boost::proto::shift_right
> <
> EmtnTermOrGram,
> boost::proto::terminal<boost::proto::_>
> >,
> boost::proto::if_
> <
> arity_caller::CanBeCalled
> <
> boost::proto::_value(boost::proto::_right),
> EmtnTermOrGram(boost::proto::_left)
> >::type
> >
> >
> {};

When you access a member of a class template, it causes the template to
be instantiated. CanBeCalled cannot legally be instantiated with two
function types. Hence the error.

Also, proto::if_ takes as it's template parameter a Transform. It should
be a transform that evaluates to a compile-time Boolean.

You can easily solve both problems by making the parameter to if_ an
ObjectTransform, as follows:

struct EmtnShiftFObjGram:
  boost::proto::and_
  <
    boost::proto::shift_right
    <
      EmtnTermOrGram,
      boost::proto::terminal<boost::proto::_>
>,
    boost::proto::if_
    <
      arity_caller::CanBeCalled
      <
        boost::proto::_value(boost::proto::_right),
        EmtnTermOrGram(boost::proto::_left)
>()
>
>
{};

Hope that helps,

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net