本文整理汇总了C++中TemplateDeclaration类的典型用法代码示例。如果您正苦于以下问题:C++ TemplateDeclaration类的具体用法?C++ TemplateDeclaration怎么用?C++ TemplateDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TemplateDeclaration类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: inferApplyArgTypesZ
void inferApplyArgTypesZ(TemplateDeclaration *tstart, Parameters *arguments)
{
for (TemplateDeclaration *td = tstart; td; td = td->overnext)
{
if (!td->scope)
{
error("forward reference to template %s", td->toChars());
return;
}
if (!td->onemember || !td->onemember->toAlias()->isFuncDeclaration())
{
error("is not a function template");
return;
}
if (!td->parameters || td->parameters->dim != 1)
continue;
TemplateParameter *tp = td->parameters->tdata()[0];
TemplateAliasParameter *tap = tp->isTemplateAliasParameter();
if (!tap || !tap->specType || tap->specType->ty != Tfunction)
continue;
TypeFunction *tf = (TypeFunction *)tap->specType;
if (inferApplyArgTypesY(tf, arguments) == 0) // found it
return;
}
}
开发者ID:odis-project,项目名称:ldc,代码行数:25,代码来源:opover.c
示例2: getFuncTemplateDecl
Module *Dsymbol::getAccessModule()
{
//printf("Dsymbol::getAccessModule()\n");
TemplateDeclaration *td = getFuncTemplateDecl(this);
if (td)
return td->getAccessModule();
Dsymbol *s = this;
while (s)
{
//printf("\ts = %s '%s'\n", s->kind(), s->toPrettyChars());
Module *m = s->isModule();
if (m)
return m;
TemplateInstance *ti = s->isTemplateInstance();
if (ti && ti->enclosing)
/* Because of local template instantiation, the parent isn't where the access
* rights come from - it's the template declaration
*/
s = ti->tempdecl;
else
s = s->parent;
}
return NULL;
}
开发者ID:Nishi,项目名称:dmd,代码行数:25,代码来源:dsymbol.c
示例3: visit
void visit(Declaration* declaration)
{
TemplateDeclaration *templateDecl = dynamic_cast<TemplateDeclaration*>(declaration);
if (templateDecl && (templateDecl->instantiatedFrom() && !templateDecl->specializedFrom().isValid()))
return; //Instantiations are tested on request
KDevelop::DeclarationValidator::visit(declaration);
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例4: search_function
FuncDeclaration *StructDeclaration::buildOpEquals(Scope *sc)
{
Dsymbol *eq = search_function(this, Id::eq);
if (eq)
{
for (size_t i = 0; i <= 1; i++)
{
Expression *e =
i == 0 ? new NullExp(loc, type->constOf()) // dummy rvalue
: type->constOf()->defaultInit(); // dummy lvalue
Expressions *arguments = new Expressions();
arguments->push(e);
// check identity opEquals exists
FuncDeclaration *fd = eq->isFuncDeclaration();
if (fd)
{ fd = fd->overloadResolve(loc, e, arguments, 1);
if (fd && !(fd->storage_class & STCdisable))
return fd;
}
TemplateDeclaration *td = eq->isTemplateDeclaration();
if (td)
{ fd = td->deduceFunctionTemplate(sc, loc, NULL, e, arguments, 1);
if (fd && !(fd->storage_class & STCdisable))
return fd;
}
}
return NULL;
}
if (!needOpEquals())
return NULL;
//printf("StructDeclaration::buildOpEquals() %s\n", toChars());
Parameters *parameters = new Parameters;
parameters->push(new Parameter(STCin, type, Id::p, NULL));
TypeFunction *tf = new TypeFunction(parameters, Type::tbool, 0, LINKd);
tf->mod = MODconst;
tf = (TypeFunction *)tf->semantic(loc, sc);
FuncDeclaration *fop = new FuncDeclaration(loc, 0, Id::eq, STCundefined, tf);
Expression *e = NULL;
/* Do memberwise compare
*/
//printf("\tmemberwise compare\n");
for (size_t i = 0; i < fields.dim; i++)
{
Dsymbol *s = fields[i];
VarDeclaration *v = s->isVarDeclaration();
assert(v && v->storage_class & STCfield);
if (v->storage_class & STCref)
assert(0); // what should we do with this?
// this.v == s.v;
EqualExp *ec = new EqualExp(TOKequal, loc,
new DotVarExp(loc, new ThisExp(loc), v, 0),
new DotVarExp(loc, new IdentifierExp(loc, Id::p), v, 0));
if (e)
e = new AndAndExp(loc, e, ec);
else
e = ec;
}
if (!e)
e = new IntegerExp(loc, 1, Type::tbool);
fop->fbody = new ReturnStatement(loc, e);
members->push(fop);
fop->addMember(sc, this, 1);
sc = sc->push();
sc->stc = 0;
sc->linkage = LINKd;
fop->semantic(sc);
sc->pop();
//printf("-StructDeclaration::buildOpEquals() %s\n", toChars());
return fop;
}
开发者ID:MadSkipjack,项目名称:dmd,代码行数:83,代码来源:clone.c
示例5: addDeclarationScopeIdentifier
void ADLHelper::addAssociatedClass(Declaration * declaration)
{
if (!declaration || !m_context || !m_topContext)
return;
// from the standard:
// Typedef names and using-declarations used to specify types do not contribute to this set.
if (declaration->isTypeAlias())
return;
if(m_alreadyProcessed.contains(declaration))
return;
m_alreadyProcessed.insert(declaration);
addDeclarationScopeIdentifier(declaration);
/*
Here comes the standard on template ADL, along with my interpretation:
This works just like for classes or class members:
If T is a template-id, its associated namespaces and classes are the namespace in which the template is
defined; for member templates, the member template's class;
This means that if the template's argument T is a type, treat it just like any other function argument.
GCC seems to include fully instantiated templates (which are a type indeed) here, so I followed the same
interpretation.
the namespaces and classes associated
with the types of the template arguments provided for template type parameters (excluding template
template parameters);
If the template's argument T is a template, take just its namespace, and not associated classes or
the namespaces associated with its own arguments.
the namespaces in which any template template arguments are defined; and the
classes in which any member templates used as template template arguments are defined.
This means when we are processing template arguments we need to skip numeric template arguments,
i.e. enumeration values (not types!), function pointers, integral values etc
[Note: non-
type template arguments do not contribute to the set of associated namespaces. ]
*/
TemplateDeclaration * templateDecl = dynamic_cast<TemplateDeclaration*>(declaration);
bool isFunctionArg = (m_templateArgsDepth == 0);
bool isTemplateClassArg = (m_templateArgsDepth > 0 && !templateDecl);
bool isTemplateTemplateArg = (templateDecl ? (templateDecl->instantiatedFrom() == NULL) : false);
if (isFunctionArg || (isTemplateClassArg && !isTemplateTemplateArg))
addBaseClasses(declaration);
if (templateDecl && !isTemplateTemplateArg)
{
///@todo Probably the parent has to be considered too (see previousInstantiationInformation), ouch
m_templateArgsDepth++;
const InstantiationInformation& instantiationInfo = templateDecl->instantiatedWith().information();
for (unsigned int i = 0, n = instantiationInfo.templateParametersSize(); i < n; ++i)
{
const IndexedType & rType = instantiationInfo.templateParameters()[i];
addArgumentType(rType.abstractType());
}
m_templateArgsDepth--;
}
}
开发者ID:alstef,项目名称:kdevelop,代码行数:62,代码来源:adlhelper.cpp
示例6: if
//.........这里部分代码省略.........
{
/* After following aliases, we found the same
* symbol, so it's not an ambiguity. But if one
* alias is deprecated or less accessible, prefer
* the other.
*/
if (s->isDeprecated() ||
s2->prot() > s->prot() && s2->prot() != PROTnone)
s = s2;
}
else
{
/* Two imports of the same module should be regarded as
* the same.
*/
Import *i1 = s->isImport();
Import *i2 = s2->isImport();
if (!(i1 && i2 &&
(i1->mod == i2->mod ||
(!i1->parent->isImport() && !i2->parent->isImport() &&
i1->ident->equals(i2->ident))
)
)
)
{
/* Bugzilla 8668:
* Public selective import adds AliasDeclaration in module.
* To make an overload set, resolve aliases in here and
* get actual overload roots which accessible via s and s2.
*/
s = s->toAlias();
s2 = s2->toAlias();
/* If both s2 and s are overloadable (though we only
* need to check s once)
*/
if (s2->isOverloadable() && (a || s->isOverloadable()))
{ if (!a)
a = new OverloadSet(s->ident);
/* Don't add to a[] if s2 is alias of previous sym
*/
for (size_t j = 0; j < a->a.dim; j++)
{ Dsymbol *s3 = a->a[j];
if (s2->toAlias() == s3->toAlias())
{
if (s3->isDeprecated() ||
s2->prot() > s3->prot() && s2->prot() != PROTnone)
a->a[j] = s2;
goto Lcontinue;
}
}
a->push(s2);
Lcontinue:
continue;
}
if (flags & 4) // if return NULL on ambiguity
return NULL;
if (!(flags & 2))
ScopeDsymbol::multiplyDefined(loc, s, s2);
break;
}
}
}
}
/* Build special symbol if we had multiple finds
*/
if (a)
{ assert(s);
a->push(s);
s = a;
}
if (s)
{
if (!(flags & 2))
{ Declaration *d = s->isDeclaration();
if (d && d->protection == PROTprivate &&
!d->parent->isTemplateMixin())
error(loc, "%s is private", d->toPrettyChars());
AggregateDeclaration *ad = s->isAggregateDeclaration();
if (ad && ad->protection == PROTprivate &&
!ad->parent->isTemplateMixin())
error(loc, "%s is private", ad->toPrettyChars());
EnumDeclaration *ed = s->isEnumDeclaration();
if (ed && ed->protection == PROTprivate &&
!ed->parent->isTemplateMixin())
error(loc, "%s is private", ed->toPrettyChars());
TemplateDeclaration *td = s->isTemplateDeclaration();
if (td && td->protection == PROTprivate &&
!td->parent->isTemplateMixin())
error(loc, "%s is private", td->toPrettyChars());
}
}
}
return s;
}
开发者ID:andralex,项目名称:dmd,代码行数:101,代码来源:dsymbol.c
注:本文中的TemplateDeclaration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论