vendredi 9 juin 2023

boost::spirit and lambda functions

My boost spirit code using lambdas for production of AST elements, does only compile if I use lambdas without capture and WITH a leading +.

does not compile:

_val = boost::phoenix::bind(
    [&](const double _d)
    {    return m_sFactory->value(_d);
    },
    qi::_1
)

compiles fine:

_val = boost::phoenix::bind(
    +[](const factory&_r, const double _d)
    {    return _r.value(_d);
    },
    *m_sFactory,
    qi::_1
)

Why is that?

Aucun commentaire:

Enregistrer un commentaire