1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Constructor template in class template.

This commit is contained in:
Markus Schorn 2009-02-09 14:45:59 +00:00
parent 5a3544dc81
commit 1c7f9d1e34
2 changed files with 19 additions and 10 deletions

View file

@ -3770,4 +3770,18 @@ public class AST2TemplateTests extends AST2BaseTest {
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
bh.assertNonProblem("A<C> make_A(C* p) {", 4, ICPPTemplateInstance.class);
}
// template <typename T> class CT {
// public:
// template <typename U> CT(U u) {}
// };
// template <typename T> void any(T t) {}
// void test() {
// int* iptr;
// any(CT<int>(iptr));
// }
public void testConstructorTemplateInClassTemplate() throws Exception {
String code= getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP);
}
}

View file

@ -607,15 +607,6 @@ public class CPPTemplates {
parentOfName= parentOfName.getParent();
}
IASTNode parentOfDeclaration= parentOfName;
while (parentOfDeclaration != null) {
if (parentOfDeclaration instanceof IASTDeclaration) {
parentOfDeclaration= parentOfDeclaration.getParent();
break;
}
parentOfDeclaration= parentOfDeclaration.getParent();
}
return parentOfName instanceof ICPPASTElaboratedTypeSpecifier ||
parentOfName instanceof ICPPASTCompositeTypeSpecifier ||
parentOfName instanceof ICPPASTNamedTypeSpecifier ||
@ -1368,7 +1359,11 @@ public class CPPTemplates {
ICPPFunctionTemplate template = (ICPPFunctionTemplate) templates.keyAt(idx);
CPPTemplateParameterMap map= new CPPTemplateParameterMap(fnArgs.length);
try {
ICPPTemplateArgument[] args= deduceTemplateFunctionArguments(template, templateArguments, fnArgs, map);
ICPPTemplateArgument[] useArgs = templateArguments;
if (template instanceof ICPPConstructor)
useArgs= ICPPTemplateArgument.EMPTY_ARGUMENTS;
ICPPTemplateArgument[] args= deduceTemplateFunctionArguments(template, useArgs, fnArgs, map);
if (args != null) {
IBinding temp= instantiateFunctionTemplate(template, args);
if (temp instanceof IFunction) {