Summary
This episode clarifies the distinction between 'requires clauses' and 'requires expressions' in C++20. Jason explains that a requires clause expects a boolean constant expression and is used with templates to constrain when functions or classes are available, while a requires expression is a way to test if certain code would be valid for a given type. The episode demonstrates how these two features can be combined (leading to the 'requires requires' syntax) and shows practical examples of using both to create constraints on template functions.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[expr.prim.req]74% match -
[temp.constr]70% match -
[temp.concept]67% match -
[temp.constr.decl]63% match -
[constraints.overview]62% match -
[constraints]61% match -
[namespace.constraints]61% match -
[temp.constr.constr]60% match -
[temp.constr.constr.general]60% match -
[structure]59% match - + 18 more related sections