I'm trying to initialize a map in a header with the following code, but it keeps giving me the error in the title. I'm using C++11, so this should be possible, right?
typedef std::map<NPCAnimation::ID, std::map<Direction::ID, sf::Time>> AnimationSpeedMap;
AnimationSpeedMap AnimationSpeeds = {
    {NPCAnimation::WALK, {
            {Direction::LEFT, sf::milliseconds(100)},
            {Direction::RIGHT, sf::milliseconds(100)},
            {Direction::UP, sf::milliseconds(200)},
            {Direction::DOWN, sf::milliseconds(200)}
        }
    },
    {NPCAnimation::IDLE, {
            {Direction::LEFT, sf::milliseconds(600)},
            {Direction::RIGHT, sf::milliseconds(600)},
            {Direction::UP, sf::milliseconds(600)},
            {Direction::DOWN, sf::milliseconds(600)}
        }
    },
    {NPCAnimation::SPECIAL, {
            {Direction::LEFT, sf::milliseconds(500)},
            {Direction::RIGHT, sf::milliseconds(500)},
            {Direction::UP, sf::milliseconds(500)},
            {Direction::DOWN, sf::milliseconds(500)}
        }
    },
};
Thanks in advance! ~ grambler1
VS2012 supports the initializer list syntax, but the VS2012 implementation of std::map does not.  You'll have to wait for support for this to be added.
I had the same issue. Unfortunately bracket-initialization and many other C++11 features are not supported until VS2013.
proof: http://msdn.microsoft.com/en-us/library/vstudio/bb386063(v=vs.120).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With