The following should work fine:
spriteBatch = std::unique_ptr<SpriteBatch>(new SpriteBatch(m_d3dContext.Get()));
Alternatively, you can avoid duplicating the type name with the make_unique function .
spriteBatch = make_unique<SpriteBatch>(m_d3dContext.Get());
Here is also a reset member :
spriteBatch.reset(new SpriteBatch(m_d3dContext.Get()));
But since you mention the constructor, why not just use a member initialization list?
CubeRenderer::CubeRenderer() : spriteBatch(new SpriteBatch(m_d3dContext.Get())) {}
R. Martinho Fernandes
source share