class TemplateTypeParmDecl

Declaration

class TemplateTypeParmDecl : public TypeDecl, private TrailingObjects { /* full declaration omitted */ };

Description

Declaration of a template type parameter. For example, "T" in

Declared at: clang/include/clang/AST/DeclTemplate.h:1205

Inherits from: TypeDecl, TrailingObjects

Member Variables

private bool Typename
If false, it was declared with the 'class' keyword.
private bool HasTypeConstraint
Whether this template type parameter has a type-constraint construct.
private bool TypeConstraintInitialized
Whether the type constraint has been initialized. This can be false if the constraint was not initialized yet or if there was an error forming the type constraint.
private bool ExpandedParameterPack
Whether this non-type template parameter is an "expanded" parameter pack, meaning that its type is a pack expansion and we already know the set of types that expansion expands to.
private unsigned int NumExpanded = 0
The number of type parameters in an expanded parameter pack.
private clang::TemplateTypeParmDecl::DefArgStorage DefaultArgument

Inherited from Decl:

protected NextInContextAndBits
protected Access
protected FromASTFile
protected IdentifierNamespace
protected CacheValidAndLinkage

Method Overview

Inherited from TypeDecl:

Inherited from NamedDecl:

Inherited from Decl:

Methods

static clang::TemplateTypeParmDecl* Create(
    const clang::ASTContext& C,
    clang::DeclContext* DC,
    clang::SourceLocation KeyLoc,
    clang::SourceLocation NameLoc,
    unsigned int D,
    unsigned int P,
    clang::IdentifierInfo* Id,
    bool Typename,
    bool ParameterPack,
    bool HasTypeConstraint = false,
    Optional<unsigned int> NumExpanded = None)

Declared at: clang/include/clang/AST/DeclTemplate.h:1248

Parameters

const clang::ASTContext& C
clang::DeclContext* DC
clang::SourceLocation KeyLoc
clang::SourceLocation NameLoc
unsigned int D
unsigned int P
clang::IdentifierInfo* Id
bool Typename
bool ParameterPack
bool HasTypeConstraint = false
Optional<unsigned int> NumExpanded = None

static clang::TemplateTypeParmDecl*
CreateDeserialized(const clang::ASTContext& C,
                   unsigned int ID)

Declared at: clang/include/clang/AST/DeclTemplate.h:1256

Parameters

const clang::ASTContext& C
unsigned int ID

static clang::TemplateTypeParmDecl*
CreateDeserialized(const clang::ASTContext& C,
                   unsigned int ID,
                   bool HasTypeConstraint)

Declared at: clang/include/clang/AST/DeclTemplate.h:1258

Parameters

const clang::ASTContext& C
unsigned int ID
bool HasTypeConstraint

TemplateTypeParmDecl(
    clang::DeclContext* DC,
    clang::SourceLocation KeyLoc,
    clang::SourceLocation IdLoc,
    clang::IdentifierInfo* Id,
    bool Typename,
    bool HasTypeConstraint,
    Optional<unsigned int> NumExpanded)

Declared at: clang/include/clang/AST/DeclTemplate.h:1239

Parameters

clang::DeclContext* DC
clang::SourceLocation KeyLoc
clang::SourceLocation IdLoc
clang::IdentifierInfo* Id
bool Typename
bool HasTypeConstraint
Optional<unsigned int> NumExpanded

static bool classof(const clang::Decl* D)

Declared at: clang/include/clang/AST/DeclTemplate.h:1401

Parameters

const clang::Decl* D

static bool classofKind(clang::Decl::Kind K)

Declared at: clang/include/clang/AST/DeclTemplate.h:1402

Parameters

clang::Decl::Kind K

bool defaultArgumentWasInherited() const

Description

Determines whether the default argument was inherited from a previous declaration of this template.

Declared at: clang/include/clang/AST/DeclTemplate.h:1292

void getAssociatedConstraints(
    llvm::SmallVectorImpl<const Expr*>& AC) const

Description

Get the associated-constraints of this template parameter. This will either be the immediately-introduced constraint or empty.

Use this instead of getConstraintExpression for concepts APIs that accept an ArrayRef of constraint expressions.

Declared at: clang/include/clang/AST/DeclTemplate.h:1393

Parameters

llvm::SmallVectorImpl<const Expr*>& AC

const clang::TemplateTypeParmDecl::DefArgStorage&
getDefaultArgStorage() const

Declared at: clang/include/clang/AST/DeclTemplate.h:1271

clang::QualType getDefaultArgument() const

Description

Retrieve the default argument, if any.

Declared at: clang/include/clang/AST/DeclTemplate.h:1278

clang::TypeSourceInfo* getDefaultArgumentInfo()
    const

Description

Retrieves the default argument's source information, if any.

Declared at: clang/include/clang/AST/DeclTemplate.h:1283

clang::SourceLocation getDefaultArgumentLoc()
    const

Description

Retrieves the location of the default argument declaration.

Declared at: clang/include/clang/AST/DeclTemplate.h:1288

unsigned int getDepth() const

Description

Retrieve the depth of the template parameter.

Declared at: clang/include/clang/AST/DeclTemplate.h:1318

unsigned int getIndex() const

Description

Retrieve the index of the template parameter.

Declared at: clang/include/clang/AST/DeclTemplate.h:1321

unsigned int getNumExpansionParameters() const

Description

Retrieves the number of parameters in an expanded parameter pack.

Declared at: clang/include/clang/AST/DeclTemplate.h:1365

clang::SourceRange getSourceRange() const

Description

Source range that this declaration covers.

Declared at: clang/include/clang/AST/DeclTemplate.h:1398

const clang::TypeConstraint* getTypeConstraint()
    const

Description

Returns the type constraint associated with this template parameter (if any).

Declared at: clang/include/clang/AST/DeclTemplate.h:1372

bool hasDefaultArgument() const

Description

Determine whether this template parameter has a default argument.

Declared at: clang/include/clang/AST/DeclTemplate.h:1275

bool hasTypeConstraint() const

Description

Determine whether this template parameter has a type-constraint.

Declared at: clang/include/clang/AST/DeclTemplate.h:1384

bool isExpandedParameterPack() const

Description

Whether this parameter is a template type parameter pack that has a known list of different type-constraints at different positions. A parameter pack is an expanded parameter pack when the original parameter pack's type-constraint was itself a pack expansion, and that expansion has already been expanded. For example, given: The parameter pack \c Convertibles has (convertible_to <Types > & & ...) as its type-constraint. When \c Types is supplied with template arguments by instantiating \c X, the instantiation of \c Convertibles becomes an expanded parameter pack. For example, instantiating\c X<int, unsigned int> results in \c Convertibles being an expanded parameter pack of size 2 (use getNumExpansionTypes() to get this number).

Declared at: clang/include/clang/AST/DeclTemplate.h:1362

bool isPackExpansion() const

Description

Whether this parameter pack is a pack expansion. A template type template parameter pack can be a pack expansion if its type-constraint contains an unexpanded parameter pack.

Declared at: clang/include/clang/AST/DeclTemplate.h:1330

bool isParameterPack() const

Description

Returns whether this is a parameter pack.

Declared at: clang/include/clang/AST/DeclTemplate.h:1324

void removeDefaultArgument()

Description

Removes the default argument of this template parameter.

Declared at: clang/include/clang/AST/DeclTemplate.h:1309

void setDeclaredWithTypename(bool withTypename)

Description

Set whether this template type parameter was declared with the 'typename' or 'class' keyword.

Declared at: clang/include/clang/AST/DeclTemplate.h:1315

Parameters

bool withTypename

void setDefaultArgument(
    clang::TypeSourceInfo* DefArg)

Description

Set the default argument for this template parameter.

Declared at: clang/include/clang/AST/DeclTemplate.h:1297

Parameters

clang::TypeSourceInfo* DefArg

void setInheritedDefaultArgument(
    const clang::ASTContext& C,
    clang::TemplateTypeParmDecl* Prev)

Description

Set that this default argument was inherited from another parameter.

Declared at: clang/include/clang/AST/DeclTemplate.h:1303

Parameters

const clang::ASTContext& C
clang::TemplateTypeParmDecl* Prev

void setTypeConstraint(
    clang::NestedNameSpecifierLoc NNS,
    clang::DeclarationNameInfo NameInfo,
    clang::NamedDecl* FoundDecl,
    clang::ConceptDecl* CD,
    const clang::ASTTemplateArgumentListInfo*
        ArgsAsWritten,
    clang::Expr* ImmediatelyDeclaredConstraint)

Declared at: clang/include/clang/AST/DeclTemplate.h:1377

Parameters

clang::NestedNameSpecifierLoc NNS
clang::DeclarationNameInfo NameInfo
clang::NamedDecl* FoundDecl
clang::ConceptDecl* CD
const clang::ASTTemplateArgumentListInfo* ArgsAsWritten
clang::Expr* ImmediatelyDeclaredConstraint

bool wasDeclaredWithTypename() const

Description

Whether this template type parameter was declared with the 'typename' keyword. If not, it was either declared with the 'class' keyword or with a type-constraint (see hasTypeConstraint()).

Declared at: clang/include/clang/AST/DeclTemplate.h:1267