Concepts library
Curated hub for the C++20 concepts library: core object concepts, comparison and relation concepts, callable concepts, and practical constraint-building routes.
The concepts library provides named constraints for templates and generic algorithms. These concepts let you express what types and operations a template expects, turning long substitution failures into explicit requirements and clearer overload selection.
# Start Here
Type identity and convertibility
Start here when your constraint is about two types matching, converting, or sharing a common type/reference.
same_as · convertible_to · common_with · common_reference_with
Object lifecycle concepts
Use this route for construction, assignment, moving, copying, destructibility, and “regular type” style requirements.
Comparison and ordering
Choose this route when the key question is equality, total ordering, or relation/predicate semantics.
equality_comparable · totally_ordered · relation · strict_weak_order
Callable and predicate concepts
Use this route for callability, predicates, and function-object style constraints in algorithms and generic code.
Fundamental category concepts
Start here when you need coarse-grained categories such as integral, floating-point, signed, or unsigned types.
integral · signed_integral · unsigned_integral · floating_point
Inheritance and swapping
Use this route for hierarchy relationships, assignability, and operations like swapping that often appear in generic APIs.
# Quick Map
| If you need to say... | Start with | Typical follow-ups |
|---|---|---|
| “These two types must be the same or interoperate through a common type” | same_as | convertible_to, common_with, common_reference_with |
| “This type must be movable/copyable/regular” | movable or regular | copyable, semiregular, destructible |
| “This callable must be invocable and maybe return a predicate/relation” | invocable | predicate, relation, equivalence_relation |
| “These values must support equality or ordering” | equality_comparable or totally_ordered | strict_weak_order, relation |
| “The type belongs to a broad arithmetic category” | integral or floating_point | signed_integral, unsigned_integral |
| “The type participates in inheritance or assignment relationships” | derived_from or assignable_from | swappable, constructible_from |
# Practical Routes
I am writing constrained templates
Use templates and constraints pages when your main problem is `requires`, constraint normalization, or template syntax around these concepts.
I need a “regular value-like type” constraint
Start here when you want a concept that implies a type behaves predictably like an ordinary value.
I need callable or predicate constraints
Start here for algorithm-style callability, predicate, and relation constraints.
I probably need ranges concepts instead
If the requirement is about iteration, views, or range-based algorithm participation, the ranges hub is usually the better first stop.
# Boundary Lines
| If you actually need... | Go here |
|---|---|
| The syntax and semantics of constrained templates, `requires` expressions, or constraint satisfaction | constraints, requires, templates |
| Iterator or range participation concepts rather than the ` | ranges, iterator |
| Older named requirements instead of standardized C++20 concepts | Named requirements |
| Type traits or detection utilities rather than named concepts | <type_traits>, type support |