IFTI, value types, and top-level const
Peter Alexander
peter.alexander.au at gmail.com
Fri Jun 7 06:58:32 PDT 2013
This code fails to compile because T is deduced to be `const int`:
void foo(T)(T x)
{
x++;
}
void main()
{
const int y = 0;
foo(y);
}
Analogous code in C++ works because C++ strips the top-level
const.
Is there any reason this isn't done in D with non-ref value type
parameters? Of course, I can use Unqual, but it is a hassle to
always remember. It also doesn't help with bloat because these
will all call different functions:
const int a;
immutable int b;
int c;
foo(a);
foo(b);
foo(c);
What is the value in things being the way they are?
More information about the Digitalmars-d
mailing list