C++ guys hate static_if?

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Mar 14 11:20:04 PDT 2013


14-Mar-2013 22:13, H. S. Teoh пишет:
> On Thu, Mar 14, 2013 at 06:09:26PM +0100, Andrej Mitrovic wrote:
>> On 3/14/13, bearophile <bearophileHUGS at lycos.com> wrote:
>>> This is an invalid argument. You can say the same thing for many
>>> (most?) tests done by the compiler. Unit tests can't be sure to
>>> verify all code paths inside a function or template.
>>
>> No, it must do exactly that. If you have so many paths that you can't
>> reasonably test all paths then your template or function is too
>> complicated to begin with. The benefit here of D over C++ is that unit
>> testing is cheap and doesn't require external libraries.
> [...]
>
> I think you're missing the point. The point is that concepts allow the
> compiler to deduce template correctness *without* instantiating it with
> every possible combination of types.
>
> Right now, we *don't* have concepts, and therefore the only way to
> ensure template correctness is to iterate over the exponential number of
> combinations of template arguments.

And if you create a library tool to try out all sensible combinations 
would that work for this use case of concepts?

In essence you transform concept to some specification and feed it into 
a CTFE-able generatopr function. Then take the code out and apply mixin 
it put into a unittest.

Sounds easy (if only DMD doesn't run out of memory in the process).



-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list