Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Can't add sf::Text to STL containers?  (Read 1841 times)

0 Members and 1 Guest are viewing this topic.

no name

  • Newbie
  • *
  • Posts: 2
    • View Profile
Can't add sf::Text to STL containers?
« 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11001
    • View Profile
    • development blog
    • Email
Re: Can't add sf::Text to STL containers?
« Reply #1 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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

no name

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Can't add sf::Text to STL containers?
« Reply #2 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!

 

anything