Concepts (C++20) in C++
From the C++ cheat sheet · Templates & Concepts · verified Jul 2026
Concepts (C++20)
Constrain template parameters readably.
cpp
// Quick Reference
#include <concepts>
template <std::integral T>
T doubleIt(T x) { return x * 2; }💡 Concepts (C++20) constrain templates so misuse fails with a clear message, not a wall of errors.
⚡ Standard concepts live in <concepts>: std::integral, std::floating_point, std::same_as, ...
📌 requires clauses and constrained auto (std::integral auto) both express the same constraint.
🟢 Concepts replace most SFINAE/enable_if tricks with far more readable code.
conceptstemplates