SFML community forums

Help => Graphics => Topic started by: no name on August 11, 2016, 12:09:37 am

Title: Can't add sf::Text to STL containers?
Post by: no name on August 11, 2016, 12:09:37 am
I just upgraded to the latest version of SFML in the hopes of fixing a small problem, but it seems like I've just created a much bigger one. I was able to put sf::Text objects in vectors in the old version but now doing so causes my program to crash.

This code causes a bad_alloc error:

Code: [Select]
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>

int main()
{
     sf::Text t;
     std::vector<sf::Text> vec;
     vec.push_back(t);
     return 0;
}

Pushing a sf::Sprite object into a vector of Sprites works fine. Only sf::Text is causing this issue. sizeof(sf::Text) is 260 bytes while sizeof(sf::Sprite) is 272 bytes so I don't think it has anything to do with memory shortage.

Did I install something wrong or can we not put sf::Text objects in containers?
Title: Re: Can't add sf::Text to STL containers?
Post by: eXpl0it3r on August 11, 2016, 01:05:06 am
This works fine for. I assume you must have some bad configuration. Do you use debug libs in release mode or release libs in debug mode? What's your compiler? What's your OS?
Title: Re: Can't add sf::Text to STL containers?
Post by: no name on August 11, 2016, 01:08:50 am
This works fine for. I assume you must have some bad configuration. Do you use debug libs in release mode or release libs in debug mode? What's your compiler? What's your OS?

Yep, problem was on my end, got it resolved (forgot to update the DLL files).

Thanks and sorry for wasting your time!