即:創建與推導出的參數類型相同的局部變量最簡單的方法是什麼?
[](auto const& foo) {
??? bar; // should be same base type as foo, minus const&
}
到目前爲止,我使用的是:
typename std::remove_const<typename std::remove_reference<decltype(foo)>::type>::type combination
但我真的希望那裏有一個更簡單的替代品!
據我所知,我是'auto'類型演繹語義學,但在我需要使用'decltype'的地方,因爲我沒有分配表達式。他們介紹'decltype(auto)foo = bar'來解決逆向問題,但現在我想'decltype(bar)foo;'; –
mmocny