#include <iostream>
#include <typeinfo>

using namespace std;

//if(flag) -> int foo(bool);
//else     -> double foo(bool);

auto foo(bool flag) ->decltype(flag ? 1 : 1.0)
{
    if(flag)    return 1;
    else        return 1.0;
}

int main()
{
    std::cout << typeid(foo(true)).name() << std::endl;
    std::cout << typeid(foo(false)).name() << std::endl;
    return 0;
}
