3 ms·
"Concepts have been widely expected to produce better error messages than are currently produced when template instantiation fails. ... Unfortunately, it turn
by _yosefk 11y ago
"Concepts have been widely expected to produce better error messages than are currently produced when template instantiation fails. ... Unfortunately, it turns out not to be so simple and use of concepts sometimes results in worse error messages. Constraint failures frequently manifest as overload resolution failures resulting in a potentially long list of candidates, each with its own list of reasons for rejection. Identifying the candidate that was intended for a given use and then figuring out why the constraint failure occurred, can be a worse experience than navigating a template instantiation stack."
Perhaps someone indeed has been "widely expecting" a huge new source of complexity in C++'s already very complex static binding rules to help produce better error messages. I personally have never met that someone.
- rat87 11y agoI'm not that into c++ but I thought better error messages was one of the main if not the main point of concepts. Basically the problem with templates is that there is no check for whether a thing can be satisfy a function/operation till it's fully expanded and it's hard to figure out where the "error" occurred during the template expansion. I thought concepts were meant to be like type classes (and type class limits to generics) in other languages so that the template writer could say that a template parameter has to implement x,y,and z and if the type passed in doesn't put the error at that expansion. An optional constraint on a feature(templates) otherwise too powerful for good error messages.
- _yosefk 11y agoWell, they didn't stop at concepts as contracts to be checked, instead they let you have a different oveload called depending on what concepts your argument types implement. Hence the problem with having to sift through potential overloads and reasons for rejection.
- vmorgulis 11y agoNew items for the FQA :-)