Fun with templates

TommiT tommitissari at hotmail.com
Sun Jul 7 04:17:23 PDT 2013


On Sunday, 7 July 2013 at 11:07:44 UTC, Marco Leise wrote:
> Am Sat, 6 Jul 2013 20:24:41 +1000
> schrieb Manu <turkeyman at gmail.com>:
>
>> On 6 July 2013 18:23, Namespace <rswhite4 at googlemail.com> 
>> wrote:
>> 
>> > That doesn't do what I want at all. The signature is still 
>> > f(T) not
>> >> f(Unqual!T).
>> >>
>> >
>> > For non-const, const and immutable inout would do it.
>> >
>> > void f(T)(inout T var)
>> >
>> 
>> Not if there's more than 1 argument, and 'inout T' is still 
>> not 'T'.
>
> Hey, inout looks like a neat solution! And it only creates one
> template instance no matter how many arguments of type
> inout(T) you use!

const would have the same effect:

void f(T)(const T var) { ... }

...but then you can't mutate var.


More information about the Digitalmars-d mailing list