C++ SFML std::thread doesn't work

by Alexander   Last Updated January 12, 2018 18:05 PM


class lasers
    Sprite sLaser;
    int ok2=0;
    void fire(Texture &t5, FloatRect bbBG, Vector2f pP)




lasers zxcv;


        thread t1(&lasers::fire, &zxcv, t5, boundingBoxBORDER, sPlayer.getPosition());



||=== Build: Debug in GAME (compiler: GNU GCC Compiler) ===|

main.cpp||In function 'int main()':|

\functional||In instantiation of 'struct std::_Bind_simple, sf::Vector2)>(lasers, sf::Texture, sf::Rect, sf::Vector2)>':|

\thread|137|required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (lasers::*)(sf::Texture&, sf::Rect, sf::Vector2); _Args = {lasers&, sf::Texture&, sf::Rect&, const sf::Vector2&}]'|

\functional|1665|error: no type named 'type' in 'class std::result_of, sf::Vector2)>(lasers, sf::Texture, sf::Rect, sf::Vector2)>'|

\functional|1695|error: no type named 'type' in 'class std::result_of, sf::Vector2)>(lasers, sf::Texture, sf::Rect, sf::Vector2)>'| ||=== Build failed: 2 error(s), 4 warning(s) (0 minute(s), 1 second(s)) ===|


I'm not sure what I'm doing wrong, as this is my first time working with threads(for a school project). I've looked at several examples including ones with classes, but somehow I haven't yet managed to make this work.

I basically want to make sprites which start from a point and go upwards until they hit something and disappear. So I figured making a class provides me with infinite functions and sprites for that, and I can just use some sequence in the main to create as many objects as I wish. Perhaps this isn't the best approach, but I think it would work if I manage to make the thread work.

Could someone give me some advice on how to get rid of the last two errors from above and finally make the thread work? Thank you.

Related Questions