返回在下面的代碼我有修改了兩本很貴對模仿對象的功能,我試圖逃脫,沒有輸出參數的std ::領帶和對象的生命週期中的元組
struct FatThing {/* some big data members here*/};
auto processFatThings(FatThing ft1, FatThing ft2)-> std::tuple<FatThing, FatThing> {
// do smth with those two
return std::make_tuple(move(ft1), move(ft2));
}
auto useProcessFatThings()-> void {
FatThing ft1, ft2;
std::tie(ft1, ft2) = processFatThings(move(ft1), move(ft2)); // dangling references?
}
我我現在有點困惑,因爲編譯器不會發出任何警告,sanitizers和memcheck是乾淨的,代碼工作。但!!!是不是在std :: tie這裏創建的懸掛引用?
爲什麼你認爲涉及懸掛引用?你沒有在任何地方使用引用,既不在函數參數中,也不在你的返回類型中。 – pschill