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


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.

Thanks,
Greg