Last Updated: May 17, 2026
Type traits are small templates in the <type_traits> header that answer questions about types at compile time. They tell you whether a type is an integer, whether it's a pointer, whether two types are the same, and they can transform one type into another, all without running any code. Modern C++ generics lean on them constantly: std::vector, std::sort, and std::optional all read type traits internally to pick the right implementation for whatever type you hand them.