【发布时间】:2017-11-21 17:37:34
【问题描述】:
我有以下向量:
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的定义是不可能的。 -
在没有
iterator指向插入位置的情况下,insert是否工作? -
Crect和CEdit是标准控件 MFC 类。
标签: c++ vector stl unique-ptr std-pair