I want to only define a function based on the size of the template parameter:
template <class T>
typename std::enable_if<sizeof(T) > 1, void>::type
foobify(T v) {
// ...
}
int main() {
//foobify((unsigned char)30); // should not compile
foobify((long)30);
}
However, I get:
main.cpp:8:41: error: expected unqualified-id before numeric constant
typename std::enable_if<sizeof(T) > 1, void>::type
It works if I instead do 1 < sizeof(T)
. Thus I believe GCC is thinking I am ending the template parameter, instead of continuing the boolean expression.
Is there any way to use >
itself without having to work around it?