Boost logo

Boost :

Subject: Re: [boost] [xpressive] capture float?
From: Greg Rubino (bibil.thaysose_at_[hidden])
Date: 2014-07-23 18:47:46


On Wed, Jul 23, 2014 at 4:07 PM, Greg Rubino <bibil.thaysose_at_[hidden]>
wrote:

> Hi all,
>
> I'm trying to capture a float with xpressive and put it into a local map.
> As a simplified example, I tried just pushing the matched pattern to a
> float and the result is always a float containing '0'.
>
> namespace xpr = boost::xpressive;
>
> std::map<float, std::string> l_floatOperMap;
>
> xpr::sregex l_relation = xpr::as_xpr("<=") | ">=" | "<" | ">");
> l_floatRestriction =
> !(xpr::s1 = l_relation) >> (xpr::s2 = (+xpr::_d >> '.' >>
> +xpr::_d))
> [xpr::ref(l_floatOperMap)[xpr::as<float>(xpr::s2)] =
> xpr::as<std::string>(xpr::s1)];
>
>
> However, when I go to print the contents of l_floatOperMap, it contains
> only the tuple (0, ""). Is it something I'm doing wrong? It seems like
> this should work to me.
>
>
I neglected to mention that I am actually doing the very same thing with
uint32_t and it works fine.

Thanks,
Greg


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