fork(1) download
  1. #include<list>
  2.  
  3.  
  4. enum Bool { False, True };
  5.  
  6.  
  7. template<Bool> struct isSingleton_;
  8. template<Bool b> using isSingleton = typename isSingleton_<b>::type;
  9. template<> struct isSingleton_<False> { using type = int; };
  10. template<> struct isSingleton_<True> { using type = std::list<int>; };
  11.  
  12.  
  13. template<Bool> struct mkSingle_;
  14. template<Bool b> auto mkSingle = mkSingle_<b>::value;
  15. template<> struct mkSingle_<False> { static const isSingleton<False> value = 0; };
  16. template<> struct mkSingle_<True> { static const isSingleton<True> value; };
  17. const isSingleton<True> mkSingle_<True>::value = {};
  18.  
  19.  
  20. int main()
  21. {
  22. auto i = mkSingle<False>;
  23. auto l = mkSingle<True>;
  24.  
  25. return i;
  26. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty