SFML / SFML-Game-Development-Book

Full and up-to-date source code of the chapters of the "SFML Game Development" book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Command.hpp - derivedAction wont compile in VS2013 Express

theCr0w1506 opened this issue · comments

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

Nevermind. I just found the fix.