Fun with templates

TommiT tommitissari at hotmail.com
Sat Jul 6 11:54:14 PDT 2013


On Saturday, 6 July 2013 at 18:07:08 UTC, Dicebot wrote:
> On Saturday, 6 July 2013 at 15:38:45 UTC, Artur Skawina wrote:
>> Do you think this would be a problem /in practice/?
>
> Yes. Honestly, lot of problems. I can easily imagine template 
> function that modifies its argument in-place for a mutable 
> qualifier and allocates a copy for an immutable one. Templates 
> that introspect their parameter type to format some string. 
> Different algorithms for processing mutable and immutable 
> versions of same container.

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.

> And it is not just code breakage - you propose some magic 
> instead of simple well-defined semantics and so far I don't 
> even see the detailed description how new system should behave.

As I understand it, it would be like what C++ does, but only for 
POD types. Just take const, immutable, whatever away when they're 
passed by value.


More information about the Digitalmars-d mailing list