Mehrdeutige Variante und Boost Spirit x3

Der Versuch, das Berechnungsbeispiel für Boost Spirit x3 zu optimieren, um Funktionen zu analysieren, die Funktionen als Argumente annehmen können. Es wird jedoch nicht kompiliert.

namespace client{ namespace ast{
    struct ts;
    struct fnc;
    typedef boost::variant<
    ts,
    boost::recursive_wrapper<fnc>
    > node;
    struct ts{
        unsigned int id;
    };
    struct fnc{
        std::vector<char> id;
        std::vector<node> args;
    };
}}
BOOST_FUSION_ADAPT_STRUCT(
    client::ast::ts,
    (unsigned int, id)
)
BOOST_FUSION_ADAPT_STRUCT(
    client::ast::fnc,
    (std::vector<char>, id)
    (std::vector<client::ast::node>, args)
)
namespace client{
    namespace x3 = boost::spirit::x3;
    namespace calc_grammar{
        using x3::uint_;
        using x3::alpha;
        using x3::alnum;
        using x3::lit;
        using x3::char_;
        x3::rule<class funct, ast::fnc> const funct("function");
        x3::rule<class ts, ast::ts> const ts("timeseries");
        x3::rule<class funct_name, std::vector<char>> const funct_name("function_name");
        auto const funct_def = funct_name >> lit('(') >> -((ts|funct)%lit(',')) >> lit(')');
        auto const ts_def = lit('#') >> uint_ >> lit('#');
        auto const funct_name_def = lit('@') >> alpha >> *(alnum|char_('_'));
        auto const calc = x3::grammar(
            "calc", 
            funct = funct_def, 
            ts = ts_def,
            funct_name = funct_name_def
        );
    }
    using calc_grammar::calc;
}

Fehler C2665: 'boost :: detail :: variant :: make_initializer_node :: apply :: initializer_node :: initialize': Keine der 5 Überladungen konnte alle Argumenttypen konvertieren

In variant.hpp gibt es auch einen Hinweis für den Benutzer

// NOTE TO USER :
// Compile error here indicates that the given type is not 
// unambiguously convertible to one of the variant's types
// (or that no conversion exists).

Trotzdem bin ich nicht der Weisere ...

Antworten auf die Frage(1)

Ihre Antwort auf die Frage