Hi there!
I got a little problem with templates:
template <typename T>
T Func(){
std::string somestr = "";
// somestr = ...
if (somestr != ""){
return boost::lexical_cast<T>(somestr);
}
else{
T ret; // warning: "ret may be uninitialized in this function"
return ret;
}
}
If this function fails to get a result, I want to return a valid object, but as empty as possible. If I do it like above, I get the warning "ret may be uninitialized in this function". Try-Catch does not help to remove the warning..
Is there a way for this like the default
keyword in C#?
return default(T); // C#
Thanks!