Why are variables of concept type forbidden?

126 views
Skip to first unread message

Andy Prowl

unread,
Mar 25, 2015, 5:29:46 AM3/25/15
to conc...@isocpp.org
According to my understanding of draft N3477, the following is not allowed:

Concept c = foo();

The paragraph that forbids it is 7.1.6.4/6:

A constrained-type-specifier shall not appear in the declared type of a variable.

Why is that the case? Wouldn't that be equivalent to the following?

auto c = foo();
static_assert(Concept<decltype(c)>);

I do understand that, for instance, the declaration below does not make sense:

Concept c;

Can't we simply require the presence of an initializer when a constrained-type-specifier is used, just like we do for auto?

Kind regards,

Andy

Tony V E

unread,
Mar 25, 2015, 1:51:20 PM3/25/15
to conc...@isocpp.org
The basic answer is just that they haven't got there yet, but they plan on getting there at some point.  The Concepts TS is big enough as is, each feature makes it bigger.

Concept c = foo();

seems simple enough, but nothing in C++ is simple, particularly at the language specification level.

Personally, Concept variables are on the top of my wish list.  I really don't like 'auto'; I'd prefer a constrained auto.

Tony


--
You received this message because you are subscribed to the Google Groups "SG8 - Concepts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concepts+u...@isocpp.org.
To post to this group, send email to conc...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/concepts/.

Reply all
Reply to author
Forward
0 new messages