|
Boost : |
Subject: Re: [boost] [proto] lazy functions in custom domains
From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2009-02-23 06:52:15
On Mon, Feb 23, 2009 at 7:43 PM, Eric Niebler <eric_at_[hidden]> wrote:
> Dean Michael Berris wrote:
>>
>> Hi Guys,
>>
>> I've recently tried to play around with Boost.Proto and I think I've
>> run into a wall. I was trying to figure this (relatively simple) case
>> out for a while already but it I'm at my wits end not seeing why the
>> implementation doesn't work.
>>
>> I'm pasting the contents of the file (unmodified) which I've tried to
>> follow from the Getting Started document. I was trying to get the
>> custom domain approach working, but I never seem to get the lazy
>> function to be called.
>
> <snip>
>
> Hi Dean,
>
> You were /so/ close to getting this to work, but you would have had to read
> more than the Getting Started guide. There is really only one error in your
> code....
>
Yup, I really should read more of the documentation in a room where I
can focus 100%. ;-)
> You create an expression extension with the BOOST_PROTO_EXTENDS() macro, and
> then also define an operator() overload. BOOST_PROTO_EXTENDS() defines
> operator() for you (check the docs) and the generated one is being preferred
> to yours because it is a non-const member function. You should use
> BOOST_PROTO_BASIC_EXTENDS() instead. Using proto::extends<> also would have
> saved you this trouble.
>
Ah, that makes sense. :-)
> There's one other minor issue: you're creating an expression with
> proto::make_expr() but not specifying the domain. That's ok in this case
> because Proto deduces your domain correctly, but in some cases it can't so
> you should specify the domain.
>
> The fixed code is below:
>
> ---->8--
>
[snip]
>
> ---->8--
>
> Hope this helps,
>
Oh my, that was quick. Thanks Eric, it does work!
Now on to fleshing out that DSEL... ;-)
-- Dean Michael Berris | Software Engineer, Friendster, Inc. blog.cplusplus-soup.com | twitter.com/mikhailberis | linkedin.com/in/mikhailberis | profiles.friendster.com/mikhailberis | deanberris.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk