[temp.concept] # 13 Templates [[temp]](./#temp) ## 13.7 Template declarations [[temp.decls]](temp.decls#temp.concept) ### 13.7.9 Concept definitions [temp.concept] [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L4684) A [*concept*](#def:concept "13.7.9 Concept definitions [temp.concept]") is a template that defines constraints on its template arguments[.](#1.sentence-1) [concept-definition:](#nt:concept-definition "13.7.9 Concept definitions [temp.concept]") concept [*concept-name*](#nt:concept-name "13.7.9 Concept definitions [temp.concept]") [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt = [*constraint-expression*](temp.constr.decl#nt:constraint-expression "13.5.3 Constrained declarations [temp.constr.decl]") ; [concept-name:](#nt:concept-name "13.7.9 Concept definitions [temp.concept]") [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L4698) A [*concept-definition*](#nt:concept-definition "13.7.9 Concept definitions [temp.concept]") declares a concept[.](#2.sentence-1) Its [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") becomes a [*concept-name*](#nt:concept-name "13.7.9 Concept definitions [temp.concept]") referring to that concept within its scope[.](#2.sentence-2) The optional [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") appertains to the concept[.](#2.sentence-3) [*Example [1](#example-1)*: templateconcept C = requires(T x) {{ x == x } -> std::[convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]");}; templaterequires C // C constrains f1(T) in [*constraint-expression*](temp.constr.decl#nt:constraint-expression "13.5.3 Constrained declarations [temp.constr.decl]") T f1(T x) { return x; }template // C, as a [*type-constraint*](temp.param#nt:type-constraint "13.2 Template parameters [temp.param]"), constrains f2(T) T f2(T x) { return x; } — *end example*] [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L4721) A [*concept-definition*](#nt:concept-definition "13.7.9 Concept definitions [temp.concept]") shall inhabit a namespace scope ([[basic.scope.namespace]](basic.scope.namespace "6.4.6 Namespace scope"))[.](#3.sentence-1) [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L4725) A concept shall not have [associated constraints](temp.constr.decl#def:associated_constraints "13.5.3 Constrained declarations [temp.constr.decl]")[.](#4.sentence-1) [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L4728) A concept is not instantiated ([[temp.spec]](temp.spec "13.9 Template instantiation and specialization"))[.](#5.sentence-1) [*Note [1](#note-1)*: A concept-id ([[temp.names]](temp.names "13.3 Names of template specializations")) is evaluated as an expression[.](#5.sentence-2) A concept cannot be explicitly instantiated ([[temp.explicit]](temp.explicit "13.9.3 Explicit instantiation")), explicitly specialized ([[temp.expl.spec]](temp.expl.spec "13.9.4 Explicit specialization")), or partially specialized ([[temp.spec.partial]](temp.spec.partial "13.7.6 Partial specialization"))[.](#5.sentence-3) — *end note*] [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L4738) The [*constraint-expression*](temp.constr.decl#nt:constraint-expression "13.5.3 Constrained declarations [temp.constr.decl]") of a [*concept-definition*](#nt:concept-definition "13.7.9 Concept definitions [temp.concept]") is an unevaluated operand ([[expr.context]](expr.context "7.2.3 Context dependence"))[.](#6.sentence-1) [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L4742) The first declared template parameter of a concept definition is its[*prototype parameter*](#def:prototype_parameter,concept "13.7.9 Concept definitions [temp.concept]")[.](#7.sentence-1) A [*type concept*](#def:concept,type "13.7.9 Concept definitions [temp.concept]") is a concept whose prototype parameter is a type template parameter[.](#7.sentence-2)