私は次のようにコーディングしましたが、C++ は初めてで、ぎこちなく感じます。「spriteBatch」(unique_Ptr) クラス スコープを指定しようとしています。ヘッダーファイルは次のとおりです。
ref class CubeRenderer : public Direct3DBase
{
public:
CubeRenderer();
~CubeRenderer();
private:
std::unique_ptr<SpriteBatch> spriteBatch;
};
次に、cpp ファイルのコンストラクターで、次のようにします。
std::unique_ptr<SpriteBatch> sb(new SpriteBatch(m_d3dContext.Get()));
spriteBatch = std::move(sb);
「sb」を作成して「spriteBatch」に移動しなければならなかった方法は、不器用に思えます。「spriteBatch」に直接代入しようとして失敗しました (適切な構文がわからないだけかもしれません)。「sb」と std::move を使用する必要を回避する方法はありますか?
ありがとうございました。