Template constraints in D
Walter Bright
newshound1 at digitalmars.com
Sun Jun 22 14:13:00 PDT 2008
Bill Baxter wrote:
> Still, anything
> containing __traits looks like an afterthought.
A bit.
> Also, I'm not sure how it's going to work in C++, but isn't the compiler
> going to have a hard time reporting errors in that kind of thing?
> Failure to instantiate could be because of a very minor typo in the big
> list of constraints.
True, you won't have an indication which failed. But you won't in C++,
either, because the overload just won't be matched.
> I'm not sure how C++ will deal with that, but I think it's another place
> where concept maps help. They introduce a little redundancy. They give
> you a place to say "I think type X satisfies concept Y, and here's how".
> That gives the compiler a place to say, "No you're wrong, type X does
> not satisfy concept Y because Foo isn't actually a method of X". It
> seems like it should be possible to generate very readable error
> messages from that.
Because you can overload based on concepts, I don't see how the compiler
can give an error message saying it failed to match part of a concept.
More information about the Digitalmars-d
mailing list