Why have both variable and function concepts in C++ Concepts TS?

淺唱寂寞╮ 提交于 2019-12-23 17:25:32

问题


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; } where E 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!