I'm sorry if this is a common question, I don't know how I'd search for it so I figured it best to just ask.
I'm wanting to define an std::array of std::pairs in C++ to store SFML sf::IntRects in. I messed with it for like 10 minutes and finally realized that this compiles:
std::array<std::pair<sf::IntRect, sf::IntRect>, 1> aliens{
{
{sf::IntRect{2,3,1,2}, sf::IntRect{4,1,3,2}}
}
};
Why do I need the extra set of curly braces around the pair itself? When I take them away:
std::array<std::pair<sf::IntRect, sf::IntRect>, 1> aliens{
{sf::IntRect{2,3,1,2}, sf::IntRect{4,1,3,2}}
};
I get an error No suitable user-defined conversion from "sf::IntRect" to "std::pair<sf::IntRect,sf::IntRect>" exists
What are these curly braces doing? I can't imagine what they'd be needed for.