Hello!
Is there any way to achieve the specified behaviour? If there is some trick or this could be done using traits or enable_if
, please let me know.
template <typename T> struct Functional {
T operator()() const {
T a(5);
// I want this statement to be tranformed into
// plain 'return;' in case T = void
return a; // <---
}
};
int main() {
Functional<int> a;
a();
Functional<void> b;
b(); // <--- Compilation error here
}