cxxheaderparser icon indicating copy to clipboard operation
cxxheaderparser copied to clipboard

[PARSE BUG]: Explicit instantiations of function templates cannot be parsed

Open asteever opened this issue 1 year ago • 3 comments

Function templates can be explicitly instantiated (including those with inferred template parameters), but cxxheaderparser will not have it.

Per https://github.com/robotpy/cxxheaderparser/blob/544c253a77d0f706418ee61b986c2b246d4eaf1f/cxxheaderparser/parser.py#L738 all instantiations must be class or struct, and the TemplateInst type seems to assume this also.

https://en.cppreference.com/w/cpp/language/function_template explicit instantiation

https://coliru.stacked-crooked.com/a/15000b7567cd61ca <- compiles fine

asteever avatar Aug 14 '24 19:08 asteever

Please post an example of the code that can't be parsed in this issue, thanks!

virtuald avatar Aug 14 '24 20:08 virtuald

https://coliru.stacked-crooked.com/a/15000b7567cd61ca is the example

#include <iostream>

template <typename T> T tFunction(T val);

template <typename T> T tFunction(T val) {
    return val;
}

template bool tFunction(bool val);

asteever avatar Sep 19 '24 00:09 asteever

Specifically, template bool tFunction(bool val); doesn't work in cxxheaderparser, but godbolt seems to accept it.

That's a weird declaration.

virtuald avatar Sep 19 '24 04:09 virtuald