c++ - Default constructing template parameters to zero if numeric? -
consider example:
template<typename t> auto f(t u, t v = t()) { return v; } int main() { double a; float b; int c; long d; // possible numerical types here auto res1 = f(a); // res1 == 0.0? auto res2 = f(b); // res2 == 0.0? auto res3 = f(c); // res3 == 0? auto res4 = f(d); // res4 == 0? }
is there guarantee standard t()
default construct 0 numerical value whenever t
numerical type? if not, how can make sure if t
numerical, default argument 'v' v = 0
, , if t
not numerical, v = t()
?
Comments
Post a Comment