Your only solution is to set one of the arguments of the function to an istream reference so that you can pass it cin. Then it can handle the input itself.
std::string my_getline(std::istream& in) {
std::string line;
if (!std::getline(in, line)) {
//input failed, throw some exception or return an empty string
}
return line;
}
//you can call functions without an intermediate variable
foo(my_getline(std::cin));