Constant template arguments

Tobias Pankrath via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 3 04:26:38 PST 2015


On Saturday, 3 January 2015 at 12:25:36 UTC, bearophile wrote:
> This doesn't compile because T is const(int) so you can't 
> modify the arguments a and b, despite they are values:
>
>
> void foo(T)(T a, T b) {
>     a = b;
>     b = a;
> }
> void main() {
>     const int x, y;
>     foo(x, y);
> }
>
>
> To make that code work I'd like to write something like this:
>
> void foo(T)(Deconst!T a, Deconst!T b) {
>
> Or this:
>
> void foo(T)(@deconst T a, @deconst T b) {
>
> Bye,
> bearophile

Like Unqual!T?


More information about the Digitalmars-d mailing list