我有以下向量:
std::vector< std::pair< std::unique_ptr<CEdit>, CRect >> m_editCtrls;
我想在这里插入一些数据:
std::unique_ptr<CEdit> edit = std::make_unique<CEdit>();
CRect rectEdit;
//Init edit....
//1 - This doesn't work
std::pair< std::unique_ptr<CEdit>, CRect > pair = std::make_pair<std::unique_ptr<CEdit>, CRect>(std::move(edit), rectEdit);
//2 - This also
m_editCtrls.insert(std::make_pair(std::move(edit), rectEdit));
在第一种情况下,我遇到了错误 - no instance of function template
,在第二种情况下 - no instance of overloaded function
。
哪种方法是将此指针插入向量的正确方法?
感谢您的帮助。
CRect
的定义,无法确定。 - undefinedinsert
会在没有指向插入位置的iterator
的情况下工作吗? - undefinedCrect
和CEdit
是标准的MFC类控件。 - undefinedstd::make_pair
中写入模板参数。 - undefined