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:謝謝! –