return type and templates
Andrea Fontana
nospam at example.com
Fri Nov 22 01:24:38 PST 2013
I've seen many different topic about this, but they don't explain
what's wrong with this "proposed" feature. Who can explain me why
this can't be added to language? Does it broke something?
// Trivial example:
struct Test
{
@property
auto value(T)() if (is(T == int)) { return _intValue; }
@property
void value(T)(T val) if (is(T == int)) { _intValue = val; }
private int _intValue;
}
void main()
{
Test s;
s.value!int(3); // Works
s.value(3); // Works, magic
s.value = 3; // Works, magic
int t1 = s.value!int; // Works
auto t2 = s.value!int; // Works
auto t4 = s.value; // Doesn't work (and i don't think it should)
int t3 = s.value; // <--Doesn't work (can this feature be
implemented?)
}
More information about the Digitalmars-d-learn
mailing list