[cfe-dev] TemplateArgumentList of out-of-line method of class template

Konstantin Tokarev annulen at yandex.ru
Sun Oct 28 03:56:28 PDT 2012


Hi all,

Is it possible to get TemplateArgumentList from declaration of out-of-line method of class template, e.g.

template<typename T1, typename T2> 
class B
{
public:
    static void hello();
};

template<typename T1, typename T2> 
void B<T1, T2>::hello()  // <---- Here
{
}

?

Background:

I'm trying to set up one-one relationships between TemplateTypeParmDecl's in method definition and in base ClassTemplateDecl (e.g. find out that T1 inside hello() definition refers to the first parameter of B).

I've tried to use template parameter declaration obtained from DeclaratorDecl::getTemplateParameterList(), however 1) there may be several template lists in CXXMethodDecl; 2) parameter ordering is not necessarily the same as in parameter list of B. Using TemplateArgumentList in B<T1, T2>::hello() should be more reliable.

-- 
Regards,
Konstantin



More information about the cfe-dev mailing list