Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 0.39 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. C   template: How to put nontype constraints in compiling time
  2. template<unsigned char I, unsigned char F>
  3. class FOO
  4. {
  5.    ....
  6. }
  7.        
  8. FOO<1, 2> a;
  9.        
  10. template<unsigned char I, unsigned char F>
  11. FOO<I,F>::FOO()
  12. {
  13.     static_assert(I >= F, "I needs to be larger or equal to F");
  14.     ...
  15. }
  16.        
  17. static int const error_size = I >= F ? 1 : -1;
  18. typedef char ERROR_I_must_not_be_less_than_F[error_size];