-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template declarations with no definition. #86
Comments
A template declaration is a mapping that always produces a result: the declaration being parameterized (e.g. the current instantiation in the case of a class template definition). That declaration being parameterized may not have a definition itself, but the template is always a mapping. So given
the template Similarly,
is a named mapping that takes a type and produces the function definition. In both cases the mapping is the mapping taking a type and producing a declaration. Same logic for the class template declaration vs. class template definition. |
I agree with the explanation of templates conceptionally and I misused definition in this case. The question I had is focused on how to represent a forward declaration of a template mapping and how that interacts with the current interface without resulting in a crash. Let's focus on the code snippet below in isolation. To my understanding this would be represented as a Template Decl node which is a mapping of the template param T to the mapping of the function (param 'x' -> void). The problem here is that mapping of the function (not the template) has no result itself despite a Mapping being defined as always having a result in the interface. template<typename T = int> void foo(T x); So nothing about the Template Decl node is invalid but if you were to call |
Since the definition here is missing - because it is just a non-defining declaration - isn't a |
Similar to issue #21 a forward declaration of a function template (with no body) is not possible as mapping is assumed to always have a result. It is similarly unclear how to represent class template decelerations with no definition.
In the case of function template mapping the
.result()
should be a mapping of Parameters to a non-existent body.In the case of a class template mapping the
.result()
should be nothingA possible solution to this is to make the result optional which was also suggested in #21.
The text was updated successfully, but these errors were encountered: