Does anyone know the best way to return a rule from a function by
value? I know that the following does not work, but what's the best
workaround?
struct calculator : grammar<calculator> {
template <typename ScannerT> struct definition {
definition(const calculator&) {
r = make_complex_rule('A') | make_complex_rule('B');
}
typedef rule<ScannerT> rule_type;
rule_type const& start() { return r;}
private:
rule_type make_complex_rule(char c) {
return c >> real_p; //boom
}
rule_type r;
};
};
my current workaround is the following nastiness:
//inside struct calculator::definition<>
rule_type& anonymous_rule() {
anonymous_rules.push_back(
boost::shared_ptr