diff --git a/SDL2pp/Point.cc b/SDL2pp/Point.cc index 3084af7..0bb5560 100644 --- a/SDL2pp/Point.cc +++ b/SDL2pp/Point.cc @@ -81,4 +81,8 @@ int Point::GetY() const { return point_->y; } +void Point::Swap(Point& other) noexcept { + point_.swap(other.point_); +} + } diff --git a/SDL2pp/Point.hh b/SDL2pp/Point.hh index 69e06c1..29b932c 100644 --- a/SDL2pp/Point.hh +++ b/SDL2pp/Point.hh @@ -61,6 +61,8 @@ public: int GetX() const; int GetY() const; + + void Swap(Point& other) noexcept; }; } diff --git a/SDL2pp/Rect.cc b/SDL2pp/Rect.cc index ce201e2..fe01c9c 100644 --- a/SDL2pp/Rect.cc +++ b/SDL2pp/Rect.cc @@ -111,4 +111,8 @@ int Rect::GetY2() const { return rect_->y + rect_->h; } +void Rect::Swap(Rect& other) noexcept { + rect_.swap(other.rect_); +} + } diff --git a/SDL2pp/Rect.hh b/SDL2pp/Rect.hh index 3cdf9ac..262d719 100644 --- a/SDL2pp/Rect.hh +++ b/SDL2pp/Rect.hh @@ -59,6 +59,8 @@ public: int GetH() const; int GetX2() const; int GetY2() const; + + void Swap(Rect& other) noexcept; }; } diff --git a/SDL2pp/Texture.cc b/SDL2pp/Texture.cc index dfaee37..66d4fb1 100644 --- a/SDL2pp/Texture.cc +++ b/SDL2pp/Texture.cc @@ -56,4 +56,10 @@ void Texture::SetAlphaMod(Uint8 alpha) { throw Exception("SDL_SetTextureAlphaMod failed"); } +void Texture::Swap(Texture& other) noexcept { + SDL_Texture* tmp = other.texture_; + other.texture_ = texture_; + texture_ = tmp; +} + } diff --git a/SDL2pp/Texture.hh b/SDL2pp/Texture.hh index acdbea7..4a2b562 100644 --- a/SDL2pp/Texture.hh +++ b/SDL2pp/Texture.hh @@ -51,6 +51,8 @@ public: void SetBlendMode(SDL_BlendMode blendMode); void SetAlphaMod(Uint8 alpha); + + void Swap(Texture& other) noexcept; }; }