I have a class Block that inherits from a class case :
class Case {
public:
Case(sf::Vector2f const& pos, sf::IntRect const& textureRect, int type = 1);
protected:
int type_;
sf::Vector2f pos_;
sf::FloatRect hitBox_;
sf::IntRect textureRect_;
};
class Block : public Case {
public:
Block(sf::Texture* const& texture, sf::Vector2f const& pos, sf::IntRect const& textureRect, int const& type = 2);
sf::Sprite& getSprite();
private:
std::shared_ptr<sf::Texture> texture_;
sf::Sprite sprite_;
};
(Both constructor are really basic, I'm not using any new anywhere)
and I have an unordered_map of unordered map to stock my blocks :
std::unordered_map<int, std::unordered_map<int, Block>> blocks_;
But when I try to delete one :
if(blocks_[i%lenght].find((i-i%lenght)/lenght) != blocks_[i%lenght].end())
blocks_[i%lenght].erase((i-i%lenght)/lenght);
I get thos error :
double free or corruption (out)
I tried to print the destructor, only the destructor from Block is called before I get this error.
It's been around 2 hours I'm looking for a solution so I finally ask it here, Thanks !