3
我有以下课程,我想添加到map
作为shared_ptr
。无法使用std :: shared_ptr作为std :: map中的值类型?
struct texture_t
{
hash32_t hash;
uint32_t width;
uint32_t height;
uint32_t handle;
};
所以我尝试使用make_pair
然后将其添加到map
...
auto texture = std::make_shared<texture_t>(new texture_t());
std::make_pair<hash32_t, std::shared_ptr<texture_t>>(hash32_t(image->name), texture);
而且在make_pair
,我收到以下编译错误:
error C2664: 'std::make_pair' : cannot convert parameter 2 from 'std::shared_ptr<_Ty>' to 'std::shared_ptr<_Ty> &&'
我觉得像我失去了明显的东西,任何线索?
修好了吧,谢谢! :) –
对'make_shared'的调用也是错误的。这已经在[OP的后续问题](http://stackoverflow.com/questions/18433712/trouble-constructing-shared-ptr/)中得到解决,但在此可能值得一提的是完整性。 – juanchopanza
@juanchopanza:谢谢! –