Another day in the ordeal of cartesianProduct

Peter Alexander peter.alexander.au at gmail.com
Mon Oct 29 09:00:47 PDT 2012


On Monday, 29 October 2012 at 14:47:37 UTC, Don Clugston wrote:
> One fairly non-disruptive thing we could do: implement code 
> coverage for templates. Currently, templates get no code 
> coverage numbers.
> We could do a code-coverage equivalent for templates: which 
> lines actually got instantiated?
> I bet this would show _huge_ gaps in the existing test suite.

That's a good step forward, but I don't think it solves (what 
appears to me to be) the most common issue: incorrect/missing 
template constraints.

auto average(R)(R r) if (isForwardRange!R)
{
     return reduce!("a + b")(r) / walkLength(r);
}

(This code can have full coverage for some ranges, but also needs 
to also check !isInfinite!R, and probably other things).

These are difficult because every time a constraint changes, you 
need to go round and update the constraints of all calling 
functions. It's like when you change the types of a function 
argument, or return type; except that with template constraints, 
nothing is checked until instantiation.


More information about the Digitalmars-d mailing list