fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct SomeType {
  5. template< bool condition >
  6. void init();
  7. };
  8.  
  9. template<>
  10. void SomeType::init< true >() {
  11. cout << "do some init" << endl;
  12. }
  13. template<>
  14. void SomeType::init< false >() {
  15. cout << "do some other init" << endl;
  16. }
  17.  
  18. int main() {
  19. SomeType t;
  20. t.init< true >();
  21. SomeType f;
  22. f.init< false >();
  23. return 0;
  24. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
do some init
do some other init