1
因爲我想要run
使用所有其他元組元素,所以需要這樣做。基本上,我有這些元組的矢量形成一種表格。我無法弄清楚自己如何正確地做到這一點。我可以在元組內分配/移動一個新值到unique_ptr嗎?
編輯:顯然以前,簡化的代碼給出了一個不同的錯誤,所以忽略它。這裏的代碼是我的代碼中的代碼。 (對不起)
class GUI {
using win_t = std::tuple<sf::RenderWindow&, Container&, std::unique_ptr<std::thread>, std::condition_variable>;
enum { WINDOW, CONT, THREAD, CV }
std::vector<win_t> windows;
void run(win_t &win);
win_t &addWindow(sf::RenderWindow & window, Container & c) {
windows.emplace_back(std::forward_as_tuple(window, c, nullptr, std::condition_variable()));
win_t &entry = windows.back();
std::get<GUI::THREAD>(entry) = std::make_unique<std::thread>(&GUI::run, this, entry); // error is on this line
return entry;
}
}
和錯誤我得到:
Error C2280 'std::tuple<sf::RenderWindow &,Container &,std::unique_ptr<std::thread,std::default_delete<_Ty>>,std::condition_variable>::tuple(const std::tuple<sf::RenderWindow &,Container &,std::unique_ptr<_Ty,std::default_delete<_Ty>>,std::condition_variable> &)': attempting to reference a deleted function dpomodorivs c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple 75`
你嘗試了上面?什麼地方出了錯? – Yakk
請提供[mcve],幷包括您遇到的錯誤。 – Barry
對不起。現在好點了嗎? – snowflake