Boost logo

Boost Users :

Subject: Re: [Boost-users] [Xpressive] Placeholder for user defined assertion
From: Eric Niebler (eniebler_at_[hidden])
Date: 2014-05-22 01:05:20


On 5/14/2014 9:59 AM, LOL wrote:
> I am trying to use a placeholder object for the check function in an
> xpressive regex. The error I usually get is "error C2064: term does
> not evaluate to a function taking 1 arguments"
>
> Please see my example below that uses the three_or_six user-defined
> assertion as described at
> http://www.boost.org/doc/libs/1_51_0/doc/html/xpressive/user_s_guide.html#boost_xpressive.user_s_guide.semantic_actions_and_user_defined_assertions.user_defined_assertions.
>
> I am using boost 1.51 and Visual Studio 2010 Express.

You can't use a placeholder in an assertion like that, sorry. But see below.

> This is a contrived example; the real reason I am trying to do this
> is because my assertion has state that is not known at the time the
> regex is compiled. In the interim I have worked around it by using
> static variables instead of placeholders but that makes for more
> brittle code than I would like.

What you can do I use by_ref to embed one regex by reference into
another. That way, your outer regex can be defined up front, and the
inner regex can be assigned later, once the user-defined assertion is known.

Alternatively, your user-defined assertion can store its data in an impl
that gets filled in later.

Hope that helps,

-- 
Eric Niebler
Boost.org
http://www.boost.org

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