- C template: How to put nontype constraints in compiling time
- template<unsigned char I, unsigned char F>
- class FOO
- {
- ....
- }
- FOO<1, 2> a;
- template<unsigned char I, unsigned char F>
- FOO<I,F>::FOO()
- {
- static_assert(I >= F, "I needs to be larger or equal to F");
- ...
- }
- static int const error_size = I >= F ? 1 : -1;
- typedef char ERROR_I_must_not_be_less_than_F[error_size];