fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3.  
  4. using namespace std;
  5.  
  6. //if(flag) -> int foo(bool);
  7. //else -> double foo(bool);
  8.  
  9. auto foo(bool flag) ->decltype(flag ? 1 : 1.0)
  10. {
  11. if(flag) return 1;
  12. else return 1.0;
  13. }
  14.  
  15. int main()
  16. {
  17. std::cout << typeid(foo(true)).name() << std::endl;
  18. std::cout << typeid(foo(false)).name() << std::endl;
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
d
d