devops.cpp.ast.checks.enforce_typename_over_class

Flag use of class instead of typename for a template type parameter.

A template type parameter can be introduced with either class or typename — they are equivalent. Standardizing on typename keeps the keyword’s meaning unambiguous: class then always refers to a class declaration, never to “some type”.

To disable this check for a project set:

[cpp]
ast_check_disabled_ids = ["enforceTypenameOverClass"]

Classes

EnforceTypenameOverClass()

Flag a template type parameter declared with class.

class devops.cpp.ast.checks.enforce_typename_over_class.EnforceTypenameOverClass[source]

Bases: Check

Flag a template type parameter declared with class.

id: str = 'enforceTypenameOverClass'

unique id, used as the cppcheck-style [id] suffix

visit(cursor, filename)[source]

Flag the cursor if it is a class-spelled template type parameter.

Parameters:
  • cursor (clang.Cursor) – The AST node currently being visited.

  • filename (str) – Path of the file being checked.

Returns:

list[Diagnostic] – A single diagnostic if the cursor is a template type parameter introduced with class, otherwise an empty list.

Return type:

list[Diagnostic]