I tried this and it doesn't compile either.
/// Otherwise, load the Shader
m_shaders.emplace(rName, sf::Shader());
if (!m_shaders.at(rName).loadFromFile(ResourcePath() + rFilename, type))
{
std::cout << "ResourceManager error: Could not load Shader: \"" << rName << "\".\n";
m_shaders.erase(rName);
return m_shaders.at("ADDDEFAULTSHADER");
}
return m_shaders.at(rName);
To confirm that this isn't just a problem with my implementation in this case, I used an sf::Texture instead, which compiled successfully:
/// Otherwise, load the Shader
m_textures.emplace(rName, sf::Texture());
if (!m_shaders.at(rName).loadFromFile(ResourcePath() + rFilename, type))
{
std::cout << "ResourceManager error: Could not load Shader: \"" << rName << "\".\n";
m_shaders.erase(rName);
return m_shaders.at("ADDDEFAULTSHADER");
}
return m_shaders.at(rName);
Correct me if I'm wrong, but wouldn't the sf::Shader need a move constructor, which would let us do std::move to place it in an STL container? We could then use it like this (which currently doesn't work because of sf::NonCopyable):
/// Otherwise, load the Shader
sf::Shader shader;
if (!shader.loadFromFile(ResourcePath() + rFilename, type))
{
std::cout << "ResourceManager error: Could not load Shader: \"" << rName << "\".\n";
return m_shaders.at("ADDDEFAULTSHADER");
}
m_shaders.emplace(rName, std::move(shader));
return m_shaders.at(rName);