fork download
  1. #include <iostream>
  2.  
  3. template <typename T>
  4. struct marker
  5. {
  6. static const bool init;
  7.  
  8. marker() { init; }
  9. };
  10.  
  11. template <typename T>
  12. const bool marker<T>::init = ([](){ std::cout << "init done\n"; return true; })();
  13.  
  14. class foo : public marker<foo>
  15. {
  16.  
  17. };
  18.  
  19. int main(int argc, const char * argv[])
  20. {
  21. foo f;
  22.  
  23. std::cout << "Hello World\n";
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
init done
Hello World