Fun with templates

Tommi tommitissari at hotmail.com
Sun Jul 7 11:28:37 PDT 2013


On Sunday, 7 July 2013 at 17:48:17 UTC, Dicebot wrote:
> On Saturday, 6 July 2013 at 18:54:16 UTC, TommiT wrote:
>> He's talking about changing the semantics only on POD types, 
>> like int, struct of ints, static array of ints... only types 
>> that can implicitly convert from immutable to mutable.
>
> Than it does not really solve anything. Have you measured how 
> much template bloat comes from common meta-programming tools 
> like std.algorithm and how much - from extra instances for 
> qualified POD types? It is better to solve broad problem 
> instead and get this special case for free, not add more 
> special cases in a desperate attempts to contain it.

Basically all I know about the performance issue being discussed 
here is that: "Code bloat is bad, m'kay". But note that Artur's 
suggestion would also change language semantics to a more 
sensible and convenient default. For example:

void foo(T)(T value)
if (isIntegral!T)
{
    value = 42;
}

...I can feel free to mutate 'value' without having to worry 
about somebody breaking my function by calling it with an 
argument of type like const(int), immutable(short), shared(long) 
...


More information about the Digitalmars-d mailing list