I have a templated class
template< std::size_t Size >
class Buffer
{
....
};
I'd like to prevent instantiation of this template when the Size argument is zero. i.e. generate a compiler warning for the following.
Buffer< 0 > buf;
but all other variants would work.
Buffer< 10 > buf;
I'm looking at using boost::enable_if_c but I don't understand how to get it working.
--Update-- I can't use any c++11 features, unfortunately
Simply specialize the template to a state that cannot be instatiated:
template <>
class Buffer<0>;
That way the class cannot be constructed. Usage will result in:
error: aggregate ‘Buffer<0> buf’ has incomplete type and cannot be defined
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With