Libclang python绑定获取模板方法专门化类型

2024-10-05 11:40:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用libclang绑定(为了方便:https://pypi.org/project/libclang/)。 我有以下代码(最少的示例):

struct TemplateFunctionSpecHolder
{
    template<typename T>
    int templateMethodSpec_1(double b) { return 7;}
};

template<>
int TemplateFunctionSpecHolder::templateMethodSpec_1<char>(double b)
{
    return 8;
}

我已将光标指向第二种方法(模板规范)。不幸的是,cursor.get_num_template_arguments()、cursor.type.get_num_template_arguments()和其他(例如cursor.canonical.get_num_template_arguments())给了我-1。任何获取模板参数的方法都不起作用。 有没有办法获得专门的模板类型?使用cursor.tokens是非常糟糕的


Tags: 方法httpspypi模板getreturntemplatearguments

热门问题