3

mapとして aに追加したい次のクラスがありますshared_ptr

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> &&'

明らかな何かが欠けているように感じますが、手がかりはありますか?

4

1 に答える 1

5

std::make_pair明示的なテンプレート パラメーターと一緒に使用することは意図されていません。それらをそのままにしておきます:

auto my_pair = std::make_pair(hash32_t(image->name), texture);

注: make_shared の呼び出しも間違っています。パラメータは のコンストラクタに渡されるtexture_tため、この場合は次のようになります。

auto texture = std::make_shared<texture_t>();
于 2013-08-25T20:19:25.153 に答える