An default values for generics
goodwin
artem.3a at gmail.com
Wed Jan 23 18:05:38 PST 2013
Hello everybody.
I started to study the D programming language and i write same
small library which use templates(generics) active. So i have one
question, how can i get default value for template(generic)? May
be something like this:
T someMethod(T)(bool someCondition){
if (someCondition) {
// ... do something and return result
} else {
return default(T);
}
}
I solved this problem with help small hack:
T getDefaultValue(T)(){
T default_value;
return default_value;
}
But i don't like this solution and i don't sure that it is work
in all cases. I want to use standard mechanism if it is exist.
With best regards.
PS: Sorry for my bad english. =)
More information about the Digitalmars-d
mailing list