16
General discussions / SFML and C++0x; "error: use of deleted function"
« on: October 30, 2011, 03:25:11 am »
That seems to be not working. Here is a minimal example.
It still won't compile. I get a different error, which is....cryptic to me
Code: [Select]
#include <functional>
#include <vector>
#include <SFML/Graphics.hpp>
class entity
{
public:
entity (int x)
{
sf::FloatRect rect(x, 50, 50, 50);
Shape = sf::Shape::Rectangle(rect, sf::Color::Red);
}
void update ()
{
}
void draw (sf::RenderTarget& target)
{
target.Draw(Shape);
}
private:
sf::Shape Shape;
};
int main ()
{
std::vector<entity> ents;
sf::RenderWindow win(sf::VideoMode(640, 480, 32), "test", sf::Style::Close);
entity en1(0);
entity en2(50);
entity en3(150);
ents.push_back(en1);
ents.push_back(en2);
ents.push_back(en3);
while (win.IsOpened())
{
sf::Event event;
while (win.PollEvent(event))
{
if (event.Type == sf::Event::Closed)
win.Close();
}
win.Clear(sf::Color::Black);
for_each(ents.begin(), ents.end(), std::mem_fun_ref(&entity::update));
for_each(ents.begin(), ents.end(), std::bind(std::mem_fun_ref(&entity::draw), std::ref(win)));
win.Display();
}
return 0;
}
It still won't compile. I get a different error, which is....cryptic to me