Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. // .h
  2. enum class EnumFoo {A, B, C}; // EnumClass
  3. enum class EnumTest {D, E, F}; // BtsStruct
  4.  
  5. class MyStruct {};
  6.  
  7. template <EnumFoo enumFoo>
  8. struct MyTraits
  9. {
  10. typedef int Other;
  11. static const EnumTest MY_STATIC_CONST_VALUE;
  12. static int foo(const MyStruct& myStruct)
  13. {
  14. return 0;
  15. }
  16. };
  17.  
  18. // .cpp
  19. template <EnumFoo type>
  20. const EnumTest MyTraits<type>::MY_STATIC_CONST_VALUE = EnumTest::D;
  21.  
  22. // client h
  23. template <EnumTest test>
  24. void g(test t)
  25. {
  26. h(t);
  27. }
  28.  
  29. // main.cpp
  30.  
  31. g<MyTraits<EnumFoo::A>::MY_STATIC_CONST_VALUE>();
  32.  
  33. template <EnumFoo enumFoo>
  34. struct MyTraits
  35. {
  36. typedef int Other;
  37. static const EnumTest MY_STATIC_CONST_VALUE = EnumTest::D;
  38. static int foo(const MyStruct& myStruct)
  39. {
  40. return 0;
  41. }
  42. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement