fork(2) download
  1. #include <stdint.h>
  2. #include <vector>
  3.  
  4. // Of this, I only want one instance per type,
  5. // because the table can get big.
  6. template<class T>
  7. struct LookUp
  8. {
  9. static int const SIZE = 1 << sizeof(T);
  10. std::vector<T> table;
  11.  
  12. LookUp()
  13. : table{ SIZE }
  14. {
  15. for (int i = 0; i < SIZE; ++i)
  16. {
  17. // Dummy code
  18. table[i] = i;
  19. }
  20. }
  21. };
  22.  
  23. // "Normal" template class with common code for all types.
  24. template<class T>
  25. struct LbpHelper
  26. {
  27. typedef void* image;
  28. };
  29.  
  30. // No functionality for the general case.
  31. template<class T>
  32. class Lbp
  33. {
  34. };
  35.  
  36. // But for this (among others) we have something.
  37. template<>
  38. class Lbp<uint8_t> : public LbpHelper<uint8_t>
  39. {
  40. typedef uint8_t value_type;
  41. typedef Lbp::image image;
  42.  
  43. static LookUp<value_type> _lookup; // <-- This is the mean one.
  44.  
  45. public:
  46.  
  47. // Stuff...
  48. };
  49.  
  50. LookUp<uint8_t> Lbp<uint8_t>::_lookup{};
  51.  
  52. int main()
  53. {
  54.  
  55. }
Success #stdin #stdout 0s 3224KB
stdin
Standard input is empty
stdout
Standard output is empty