SFML icon indicating copy to clipboard operation
SFML copied to clipboard

Added move constructor and move assignment operator for sf::Shader

Open Eren121 opened this issue 5 years ago • 2 comments

  • [x] Has this change been discussed on the forum or in an issue before? Yes, multiple times in multiple topics
  • [x] Does the code follow the SFML Code Style Guide?
  • [x] Have you provided some example/test code for your changes? See related issue

Related to >=C++11 change It's a syntactic change that should not break any cross-platform compatibility. The compatibility is related to the compiler and not the platform, and today most if not all modern compilers support C++11. But it can break C++03 code (any project use it?... if yes, they probably also use older versions of SFML that are also compatible with C++03).

Some tests did not pass because they aren't actually... C++11 compatible.

It's can also maybe be a change for another branch forecasting C++11.


Description

Make sf::Shader moveable, and keep not copiable.

This PR is related to the issue https://github.com/SFML/SFML/issues/1675 Code from the issue:

#include <SFML/Graphics.hpp>

sf::Shader loadShader() {
    sf::Shader shader;
    /* Probably more code here */
    return shader;
}
int main() {
    sf::Shader myShader = loadShader();
}

Eren121 avatar Jun 12 '20 16:06 Eren121

Valid points. There are different ways to implement move semantics in C++, we should agree on one.

I brought this up in the forum a while ago, see here and subsequent posts.

Bromeon avatar Dec 05 '21 17:12 Bromeon

There are different ways to implement move semantics in C++, we should agree on one.

I think it is important to keep a strong exception guarantee for move semantics. The transfer should always be intuitive, and I believe that noexcept grants this intuitiveness. I also posted my view on the forum thread you mentioned.

pparuzel avatar Dec 05 '21 21:12 pparuzel

superseded by #2277 ?

JonnyPtn avatar Nov 24 '22 09:11 JonnyPtn

Yep ^

eXpl0it3r avatar Nov 24 '22 12:11 eXpl0it3r