我遇到了 make_unique 的问题,我对此一头雾水。
_replace_find = unique_ptr<Fl_Input>(new Fl_Input{ 80, 10, 210, 25, "Find:" });
_replace_find = make_unique<Fl_Input>(Fl_Input{ 80, 10, 210, 25, "Find:" });
当我使用 make_unique 行时,它给出了这个错误,但是当我使用其他行时,它编译得很好。根据我的理解,make_unique 几乎做同样的事情,但异常安全。
Error 1 error C2248: 'Fl_Widget::Fl_Widget' : cannot access private member declared in class 'Fl_Widget' c:\program files (x86)\microsoft visual studio 12.0\vc\include\fl\fl_input_.h 488 1 hayley
我找不到任何关于 SO 上处理 make_unique 或 unique_ptr 的错误。否则我不会问这个。
一如既往地感谢您的宝贵时间和建议。
最佳答案
你可能想写
std::make_unique<FlInput>(80, 10, 210, 25, "Find:")
代替
std::make_unique<FlInput>(FlInput{80, 10, 210, 25, "Find:"})
FlInput
类似乎有一个私有(private)拷贝和/或移动构造函数,使第二种形式非法。
关于c++ - make_unique 给出错误 2248,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26579178/