C++ guys hate static_if?

Jonathan M Davis jmdavisProg at gmx.com
Thu Mar 14 15:41:32 PDT 2013


On Thursday, March 14, 2013 17:54:05 Andrei Alexandrescu wrote:
> On 3/14/13 2:38 PM, Jonathan M Davis wrote:
> > On Thursday, March 14, 2013 13:26:18 Andrei Alexandrescu wrote:
> >> Walter has measured coverage of Phobos unittests a couple of times, it's
> >> very high. But I agree it would be nice to have it as a target.
> > 
> > Though this is exactly a case where 100% unit test coverage doesn't mean
> > much. All that means is that each path has been instantiated and run. It
> > doesn't mean that it's covered enough possible instantiations to properly
> > test the template.
> 
> Concepts won't help there either.

Oh, they may not. My point was simply that while 100% code coverage is great, 
when you're dealing with templated functions, it's generally nowhere near 
enough (especially as the number of static ifs goes up), because there could 
easily be other template arguments which pass the template constraint but 
won't even compile with the template, let alone work correctly. For instance, 
while we've been getting better at it, it's generally been a weakness of 
std.range and std.algorithm that reference-type ranges aren't tested properly 
and don't work properly with various functions, and yet those same functions 
generally have good code coverage.

Really, it just means that we need to be thorough in the number of template 
instantiations tested and not think that 100% code coverage is enough, but I 
can understand people wanting to find ways to get the compiler to catch some of 
that for them.

- Jonathan M Davis


More information about the Digitalmars-d mailing list