Jonathan M Davis , dans le message (digitalmars.D:172564), a écrit : > They're likely to contain a lot of stuff negation of other template > constraints. For instance, > > auto func(R)(R range) > if(isForwardRange!R && !isBidirectionalRange!R) > {} > > auto func(R)(R range) > if(isBidirectionalRange!R) > {} > > If you have a function with very many overloads, it can be very easy to end > up > with a bunch of different template constraints which are all slightly > different. > std.algorithm.find is a prime example of this. > > But as much as it may be a bit overwhelming to print every failed constraint, > without doing that, you _have_ to go to the source code to see what they > were, > which isn't all that great (especially if it's not in a library that you > wrote > and don't normally look at the source of - e.g. Phobos). > > On the other hand, a failed instantiation of std.conv.to would print out > reams > of failed constraints...
The compiler could stop displaying at about 10 failed constrains and claim there are more. It would be best if it could figure out what are the 10 most interesting constrains, but that may not be easy! Then it's up to the programmer to use template constrains, static if and eventually pragma, to allow the compiler to display pleasant error messages. The langage could help you by allowing you to make hiearchized template constrains, but static if is a fine solution most of the time.