Consider a function
template <typename Ret>
Ret function(...) {
Ret a;
// . . . do something with a
return a;
}
If I call this as
function<void>();
the compiler says
error: variable or field 'a' declared void
error: return-statement with a value, in function returning 'void' [-fpermissive]
How do I enforce a check on in this function, for instance
template <typename Ret>
Ret function(...) {
// if (Ret is void) return;
Ret a;
// . . . do something with a
return a;
}
I know C++11 has std::is_void
and std::is_same
bool same = std::is_same<Ret, void>::value;
Anything in C++03 ? Thanks in advance.