函数结果自动&&

Function result auto&&

我知道 return 类型 autodecltype(auto) 的含义。我也知道 auto&& 用于变量声明。所以我尝试 auto&& 作为 return 类型:

template <class X, class Y>
auto a(X &&x, Y &&y) -> auto {
    return x+y;
}

template <class X, class Y>
auto b(X &&x, Y &&y) -> decltype(auto) {
    return x+y;
}

template <class X, class Y>
auto c(X &&x, Y &&y) -> auto&& {  // <----
    return x+y;
}

而且好像和decltype(auto)一样。 bc 是同一回事,还是我遗漏了什么?

b("a"s, "b") returns 临时字符串。

c("a"s, "b") returns 悬空引用。