Cpp.Type Class
Namespace: Cpp
Superclasses: ObjectWithPosition
Description
Type class represents the type of an object. This class inherits from the
class ObjectWithPosition. You can use the predicates associated with this class and the
base class with objects of this object.
Predicates
You can report a defect on Raisable types. If a type is
Printable, it can be reported in the message. For
Type objects, print the string obtained by the predicate
Cpp.Type.toString.
| Type | Raisable | Printable |
|---|---|---|
Lang.Int
| No | Yes |
Lang.String
| No | Yes |
Type
| Yes | No |
This class defines these predicates that act on the Type objects. In
addition, objects of Type class can access the predicates defined by the
base class ObjectWithPosition. An object of Type class is an object of
ObjectWithPosition class.
| Predicates | Description |
|---|---|
is(Type &t)
| Retrieves all Type objects in your C/C++ code. |
sizeInBits(Type self, Lang.Int &s)
| Retrieves the size of the type self in bits and stores the
value in s. |
sizeInBytes(Type self, Lang.Int &s)
| Retrieves the size of the type self in bytes and stores the
value in s. |
toString(Type self, Lang.String &n)
| Retrieves the string representation of the type self and
stores it in n. |
isUnsigned(Type self)
| Retrieves the Type objects that are unsigned integer
types. |
isSigned(Type self)
| Retrieves the Type objects that are signed integer
types. |
isConst(Type self)
| Retrieves the Type objects that are qualified with
const. |
isTypedef(Type self)
| Retrieves the Type objects that are typedefs. |
pointedTypeIsConst(Type self)
| Retrieves the Type objects where the pointed-to type is
const. |
isVolatile(Type self)
| Retrieves the Type objects that are qualified with
volatile. |
isRestrict(Type self)
| Retrieves the Type objects that are qualified with
restrict. |
qualified(Type self, Type &qual)
| Retrieves the qualified version of the type self and stores it in
qual. |
unqualified(Type self, Type &unqual)
| Retrieves the unqualified version of the type self and stores it in
unqual. |
strip(Type self, Type &stripped)
| Retrieves the stripped type for self by removing all
qualifiers and stores the stripped type in stripped. |
isFundamental(Type self)
| Retrieves the Type objects that are fundamental types, such
as int, char,
float. |
isArithmetic(Type self)
| Retrieves the Type objects that are arithmetic
types. |
isFloatingPoint(Type self)
| Retrieves the Type objects that are floating-point
types. |
isIntegral(Type self)
| Retrieves the Type objects that are integral types. |
isNullptrT(Type self)
| Retrieves the Type objects that represent the
nullptr_t type. |
isVoid(Type self)
| Retrieves the Type objects that represent the
void type. |
isFloat(Type self)
| Retrieves the Type objects that represent the
float type. |
isDouble(Type self)
| Retrieves the Type objects that represent the
double type. |
isLongDouble(Type self)
| Retrieves the Type objects that represent the long
double type. |
isBool(Type self)
| Retrieves the Type objects that represent the
bool type. |
isChar(Type self)
| Retrieves the Type objects that represent any
char types |
isPlainChar(Type self)
| Retrieves the Type objects that represent the plain
char type. |
isSignedChar(Type self)
| Retrieves the Type objects that represent the
signed char type. |
isUnsignedChar(Type self)
| Retrieves the Type objects that represent the
unsigned char type. |
isUnsignedShort(Type self)
| Retrieves the Type objects that represent the
unsigned short type. |
isShort(Type self)
| Retrieves the Type objects that represent the
short type. |
isUnsignedInt(Type self)
| Retrieves the Type objects that represent the
unsigned int type. |
isInt(Type self)
| Retrieves the Type objects that represent the
int type. |
isUnsignedLong(Type self)
| Retrieves the Type objects that represent the
unsigned long type. |
isLong(Type self)
| Retrieves the Type objects that represent the
long type. |
isUnsignedLongLong(Type self)
| Retrieves the Type objects that represent the
unsigned long long type. |
isLongLong(Type self)
| Retrieves the Type objects that represent the long
long type. |
isChar16T(Type self)
| Retrieves the Type objects that represent the
char16_t type. |
isChar32T(Type self)
| Retrieves the Type objects that represent the
char32_t type. |
isWcharT(Type self)
| Retrieves the Type objects that represent the
wchar_t type. |
isObject(Type self)
| Retrieves the Type objects that are object types (not
functions or void). |
isScalar(Type self)
| Retrieves the Type objects that are scalar types. |
isMemberPointer(Type self)
| Retrieves the Type objects that are pointers to
members. |
isMemberFunctionPointer(Type self)
| Retrieves the Type objects that are pointers to member
functions. |
isPointer(Type self)
| Retrieves the Type objects that are pointer types. |
pointedType(Type self, Type &p)
| Retrieves the type pointed to by the pointer type self and
stores it in p. |
underlyingType(Type self, Type &p)
| Retrieves the underlying type of self and stores it in
p. |
isEnum(Type self)
| Retrieves the Type objects that are enumeration
types. |
isScopedEnum(Type self)
| Retrieves the Type objects that are scoped enumeration
types. |
isArray(Type self)
| Retrieves the Type objects that are array types. |
isUnion(Type self)
| Retrieves the Type objects that are union
types. |
isClass(Type self)
| Retrieves the Type objects that are class types. |
isStruct(Type self)
| Retrieves the Type objects that are
struct types. |
isCompound(Type self)
| Retrieves the Type objects that are compound types. |
isReference(Type self)
| Retrieves the Type objects that are reference types
(lvalue or rvalue reference). |
isLvalueReference(Type self)
| Retrieves the Type objects that are
lvalue reference types. |
isRvalueReference(Type self)
| Retrieves the Type objects that are
rvalue reference types. |
isFunction(Type self)
| Retrieves the Type objects that are function types. |
returnType(Type self, Type &returnType)
| Retrieves the return type self and stores it in
returnType. |
numDeclaredParameters(Type self, Lang.Int &num)
| Retrieves the number of declared parameters for self and
stores it in num. |
declaredParameter(Type self, Type ¶mType, Lang.Int
&pos)
| Retrieves the declared parameter for self. The type of the
parameters are stored in paramType and position is stored in
pos. |
isVariadic(Type self)
| Retrieves the Type objects that are variadic. |
namespace(Type self, Cpp.Namespace.Namespace &namespace)
| Retrieves the namespace in which the type self is defined
and stores it in namespace. |
tagName(Type self, Lang.String &tag)
| Retrieves the tag name of the type self and stores it in
tag. |
enumConstant(Type self, Lang.String &ident, Lang.Int
&value)
| Retrieves the identifier and value for each enumerator constant in the enum
type self, storing the name in ident and the
value in value. |
Examples
In a new folder
Field, initialize a new coding standard. At the command line, enter:polyspace-query-language init
In the file
main.pql, enter this content:package main // Main PQL file defines the catalog of your PQL project. // The catalog is a collection of sections. catalog FieldExample = { #[Description("Example Section")] section ExampleSection = { #[Description("Unused public field in header"),Id(myRule)] rule ExampleRule = { defect Exampledefect = when Cpp.Field.is(&field) and field.isUnused() and field.isPublic() and field.extension(&ext) and ext == ".h" and field.filename(&fnstr) raise "Unused public field in header: \"{fnstr}\"" on field } } }Create the coding standard
Field.pschk using this command at the command line:polyspace-query-language package
Using the generated coding standard, run a Bug Finder analysis on your source file. Foe example, at the command line, enter:
The analysis reports defects on the unused member variablepolyspace-bug-finder -sources src.cpp -lang cpp -checkers-activation-file Field.pschk
unusedFieldin the header filesrc.h.
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)