This question is a followup after this one. The actual problem is that default template parameters for function templates are not supported by Visual Studios 2012 as indicated by this list.
Since default template parameters are not supported by Visual Studios 2012, is there any workaround to have the same result without it? So is it possible to define a template function such as
template <typename T, typename Ret = T>
Ret round(T val, Ret ret = Ret()) {
return static_cast<Ret>(
(val >= 0) ?
floor(val + (T)(.5)) :
ceil( val - (T)(.5))
);
}
without the use of default template arguments? The function works as
auto a = round(5.5, int()); // int a = 6
auto b = round(5.5); // double b = 6.0