const and immutable values, D vs C++?
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Thu Dec 5 12:00:23 UTC 2019
So basically, templated functions get flow-typing. I guess that
is a good reason to use templated functions more...
What is the downside? E.g.:
struct node {int value; node* next;}
node mk_node2()(){
node tmp = {2019, null};
return tmp;
}
node mk_node(){
node tmp = {2019, null};
return tmp;
}
void main() {
immutable x = mk_node2(); //succeeds
immutable y = mk_node(); //fails
}
More information about the Digitalmars-d-learn
mailing list