BShape: add move construction and assignment support
GCC 2 support is also provided with `MoveFrom` method. Change-Id: Ifedaf0b1406a5a2cb6bf3465249cea0f360e06d6 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8531 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
@@ -50,6 +50,9 @@ class BShape : public BArchivable {
|
|||||||
public:
|
public:
|
||||||
BShape();
|
BShape();
|
||||||
BShape(const BShape& other);
|
BShape(const BShape& other);
|
||||||
|
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||||
|
BShape(BShape&& other);
|
||||||
|
#endif
|
||||||
BShape(BMessage* archive);
|
BShape(BMessage* archive);
|
||||||
virtual ~BShape();
|
virtual ~BShape();
|
||||||
|
|
||||||
@@ -58,11 +61,15 @@ public:
|
|||||||
bool deep = true) const;
|
bool deep = true) const;
|
||||||
|
|
||||||
BShape& operator=(const BShape& other);
|
BShape& operator=(const BShape& other);
|
||||||
|
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||||
|
BShape& operator=(BShape&& other);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool operator==(const BShape& other) const;
|
bool operator==(const BShape& other) const;
|
||||||
bool operator!=(const BShape& other) const;
|
bool operator!=(const BShape& other) const;
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
void MoveFrom(BShape& other);
|
||||||
BRect Bounds() const;
|
BRect Bounds() const;
|
||||||
BPoint CurrentPosition() const;
|
BPoint CurrentPosition() const;
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,15 @@ BShape::BShape(const BShape& other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||||
|
BShape::BShape(BShape&& other)
|
||||||
|
{
|
||||||
|
InitData();
|
||||||
|
MoveFrom(other);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
BShape::BShape(BMessage* archive)
|
BShape::BShape(BMessage* archive)
|
||||||
:
|
:
|
||||||
BArchivable(archive)
|
BArchivable(archive)
|
||||||
@@ -250,6 +259,17 @@ BShape::operator=(const BShape& other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||||
|
BShape&
|
||||||
|
BShape::operator=(BShape&& other)
|
||||||
|
{
|
||||||
|
MoveFrom(other);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BShape::operator==(const BShape& other) const
|
BShape::operator==(const BShape& other) const
|
||||||
{
|
{
|
||||||
@@ -303,6 +323,20 @@ BShape::Clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BShape::MoveFrom(BShape& other)
|
||||||
|
{
|
||||||
|
fState = other.fState;
|
||||||
|
fBuildingOp = other.fBuildingOp;
|
||||||
|
|
||||||
|
shape_data* data = (shape_data*)fPrivateData;
|
||||||
|
fPrivateData = other.fPrivateData;
|
||||||
|
other.fPrivateData = data;
|
||||||
|
|
||||||
|
other.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
BShape::Bounds() const
|
BShape::Bounds() const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user