Constant template arguments
Meta via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jan 3 06:23:07 PST 2015
On Saturday, 3 January 2015 at 12:45:47 UTC, bearophile wrote:
>> void foo(T)(Unqual!T a, Unqual!T b) {
>> a = b;
>> b = a;
>> }
>> void main() {
>> const int x, y;
>> foo(x, y);
>> }
>
> Missing line:
>
> import std.traits: Unqual;
>
> Bye,
> bearophile
Wouldn't it be better to do this at the call site anyway? Just
use a simple function.
Unqual!T unconst(T)(T val)
if (isScalarType!T)
{
return val;
}
void foo(T)(T a, T b)
{
a = b;
b = a;
}
void main()
{
const int x, y;
foo(x.unconst, y.unconst);
}
More information about the Digitalmars-d
mailing list