Command.hpp - derivedAction wont compile in VS2013 Express
theCr0w1506 opened this issue · comments
Chris commented
template <typename GameObject, typename Function>
Command::Action derivedAction(Function fn)
{
return [=] (SceneNode& node, sf::Time dt)
{
// Check if cast is safe
assert(dynamic_cast<GameObject*>(&node) != nullptr);
// Downcast node and invoke function on it
fn(static_cast<GameObject&>(node), dt);
};
}
This function produces a compiler error C3848 in VS2013 Express on Windows 7.
It's line 33
fn(static_cast<GameObject&>(node), dt);
a non-const function is invoked by const function
Chris commented
Nevermind. I just found the fix.