问题
I've been looking at the C++1z N4377 Concepts TS draft that is being implemented in GCC 6, and I don't understand the purpose of having two different kinds of concepts: variable concepts and function concepts.
The relevant part of the draft for function concepts is [dcl.spec.concept (5.4)]
- The declaration shall have a function-body equivalent to
{ return E; }
whereE
is a constraint-expression (14.10.1.3).
and for variable concepts, in the next paragraph [(6.3)] :
- The initializer shall be a constraint-expression.
Is there anything one of them can do, that the other cannot? If not, is there a rationale for including both?
Note: the latest draft, P0121R0 doesn't change anything in this regard
回答1:
Function concepts can be overloaded on differing template parameter arity. Variable concepts provide nothing that function concepts don't, except for the ability to not put ()
in some contexts.
Eliminating variable concepts from the TS would not reduce the expressivity of concepts.
来源:https://stackoverflow.com/questions/35928595/why-have-both-variable-and-function-concepts-in-c-concepts-ts