Add a way to swap some types of objects

This commit is contained in:
Dmitry Marakasov 2013-12-18 04:39:19 +04:00
parent acebd488aa
commit 92925a9620
6 changed files with 20 additions and 0 deletions

View File

@ -81,4 +81,8 @@ int Point::GetY() const {
return point_->y;
}
void Point::Swap(Point& other) noexcept {
point_.swap(other.point_);
}
}

View File

@ -61,6 +61,8 @@ public:
int GetX() const;
int GetY() const;
void Swap(Point& other) noexcept;
};
}

View File

@ -111,4 +111,8 @@ int Rect::GetY2() const {
return rect_->y + rect_->h;
}
void Rect::Swap(Rect& other) noexcept {
rect_.swap(other.rect_);
}
}

View File

@ -59,6 +59,8 @@ public:
int GetH() const;
int GetX2() const;
int GetY2() const;
void Swap(Rect& other) noexcept;
};
}

View File

@ -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;
}
}

View File

@ -51,6 +51,8 @@ public:
void SetBlendMode(SDL_BlendMode blendMode);
void SetAlphaMod(Uint8 alpha);
void Swap(Texture& other) noexcept;
};
}