4 ms·
Concepts were supposed to be one of the big features of C++11. They weren't going to make templates more efficient, but they would make working with templates a
by maxlybbert 11y ago
Concepts were supposed to be one of the big features of C++11. They weren't going to make templates more efficient, but they would make working with templates a little easier. Eventually, they became unwieldy, and they made compilation times much worse. The Committee had the pressure to ship and fix it later that Hoare talked about in his Turing Award lecture ( http://www.cs.fsu.edu/~engelen/courses/COP4610/hoare.pdf http://www.cs.fsu.edu/~engelen/courses/COP4610/hoare.pdf ).
Surprisingly, they resisted Hoare's "mad dash" and deferred concepts. This article is about a stripped-down version of concepts that was accepted into the upcoming version of C++. It's supposed to have most of the benefits of the C++11 proposal, without the complexity.
But I have to admit that the main benefits are better error messages, explicit comments in code of what a template requires, and an additional syntax for declaring/defining templates. The C++11 proposal was more exciting, but there was a question of whether it went too far.
- ArtB 11y agoAny summary on what was omitted? I'm not a C++ programmer so going to the source wouldn't help me much, but I'd love to know.
- maxlybbert 11y agoI hadn't followed the original proposal closely, so I can't give a complete list. One feature I know about, that was implementable but very expensive, was the ability to specify multiple ways that a type could match a concept. For instance, a Sortable concept could mean the type has an operator<, or could be passed to the function compare(). I'm sure there was a way to handle cases where a type had both. But then, if you had a type with a method, say lessThan(), you could somehow specify that was an acceptable operator<, and then use anything that relied on the Sortable concept. As far as I know, that isn't in "concepts light."