fork download
  1. #include <iostream>
  2.  
  3. struct constants_concept
  4. {
  5. virtual uint32_t some_value() = 0;
  6. };
  7. template <typename Constants>
  8. struct constants_model
  9. : constants_concept
  10. {
  11. virtual uint32_t some_value() { return Constants::some; }
  12. };
  13.  
  14. struct mainnet_constants
  15. {
  16. static const uint32_t some = 1337;
  17. };
  18.  
  19. struct testnet
  20. {
  21. static const uint32_t some = 666;
  22. };
  23.  
  24. template <typename Constants=mainnet_constants>
  25. void foo()
  26. {
  27. std::cout << Constants::some << std::endl;
  28. }
  29.  
  30. struct bar
  31. {
  32. template <typename Constants=mainnet_constants>
  33. void set_cons()
  34. {
  35. cons_ = new constants_model<Constants>;
  36. }
  37. constants_concept* cons_;
  38. };
  39.  
  40. int main()
  41. {
  42. foo();
  43. foo<testnet>();
  44. bar b;
  45. //b.set_cons<testnet>();
  46. b.set_cons();
  47. std::cout << b.cons_->some_value() << std::endl;
  48. #ifdef FOFOF
  49. service foo;
  50. foo.set_crypto(bitcoin);
  51. foo.set_crypto(litecoin);
  52. bitcoin.address addr("1foobar");
  53. #endif
  54. return 0;
  55. }
  56.  
  57.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1337
666
1337