liveBook · Manning

Type trait

A type trait is a compile-time facility that queries or transforms a type and produces a result representing the requested property or type.

How 2 Manning books explain it

Modern C, Third Edition

A type trait is a compile-time operation that queries a property of a type and produces a result representing that property.

How it is used
Enables efficient type-generic features by querying argument-type properties at compile time.
How deep it goes
Develops macro requirements and implementation strategies for constants, integer types, VLAs, and pointer qualifiers.
Examples
Uses tozero, tonull, isinteger, isvla, pointer-qualification tests, and a type-directed pow macro.
What you can do after
Build compile-time type-trait macros that return boolean integer constant expressions without evaluating their arguments.

Read how Modern C, Third Edition explains type trait →

Learn C++ by Example

A type trait is a compile-time facility that exposes a property or transformation of a C++ type.

How it is used
Uses type traits to interrogate types and check whether template-related requirements are satisfied.
How deep it goes
Defines traits through a clock-checking example and stops short of detailing trait implementation internals.
Examples
Demonstrates std::chrono::is_clock<int>::value as a false result for a non-clock type.
What you can do after
Evaluate whether a type satisfies named requirements by reading a trait's Boolean value.

Read how Learn C++ by Example explains type trait →

Related concepts

Questions about type trait

What is type trait?

A type trait is a compile-time facility that queries or transforms a type and produces a result representing the requested property or type.

Which Manning books explain type trait?

Modern C, Third Edition and Learn C++ by Example.

What kinds of type trait are there?

Kinds of type trait include is_constructible.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.