This code works. This question is about making it (look) better.
I have seen known the article about utree
s but I'm not not sure that is the best way.
Let me show you the "ugly" version of the code, which uses construct<>
newcall =(nocaselit(L"new") > tyname)
[_val = construct<common_node>(type_cmd_new,key_typename, construct<std::wstring>(_1))];
With the rules declared as:
qi::rule<Iterator, common_node(), Skipper> newcall
qi::rule<Iterator, std::wstring()> tyname;
The target common AST node is:
struct common_node {
template <typename X>
common_node(node_type t, node_key k1, const X & m1)
The first parameter is the node type, the second some kind of member key and the last the payload given as template argument (later stored in a variant).
Can we avoid the construct
template?