1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-29 02:40:05 +00:00

Made some more JUCE classes trivially copyable

This commit is contained in:
Tom Poole 2018-07-11 15:07:00 +01:00
parent 4448ef6a59
commit fc87d8cd1d
11 changed files with 31 additions and 103 deletions

View file

@ -36,11 +36,7 @@ class StatisticsAccumulator
public:
//==============================================================================
/** Constructs a new StatisticsAccumulator. */
StatisticsAccumulator() noexcept
: count (0),
minimum ( std::numeric_limits<FloatType>::infinity()),
maximum (-std::numeric_limits<FloatType>::infinity())
{}
StatisticsAccumulator() = default;
//==============================================================================
/** Add a new value to the accumulator.
@ -116,7 +112,7 @@ private:
//==============================================================================
struct KahanSum
{
KahanSum() noexcept : sum(), error() {}
KahanSum() = default;
operator FloatType() const noexcept { return sum; }
void JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS operator+= (FloatType value) noexcept
@ -127,13 +123,14 @@ private:
sum = newSum;
}
FloatType sum, error;
FloatType sum{}, error{};
};
//==============================================================================
size_t count;
size_t count { 0 };
KahanSum sum, sumSquares;
FloatType minimum, maximum;
FloatType minimum { std::numeric_limits<FloatType>::infinity() },
maximum { -std::numeric_limits<FloatType>::infinity() };
};
} // namespace juce

View file

@ -68,11 +68,6 @@ static void blurSingleChannelImage (Image& image, int radius)
}
//==============================================================================
DropShadow::DropShadow() noexcept
: colour (0x90000000), radius (4)
{
}
DropShadow::DropShadow (Colour shadowColour, const int r, Point<int> o) noexcept
: colour (shadowColour), radius (r), offset (o)
{

View file

@ -36,7 +36,7 @@ namespace juce
struct JUCE_API DropShadow
{
/** Creates a default drop-shadow effect. */
DropShadow() noexcept;
DropShadow() = default;
/** Creates a drop-shadow object with the given parameters. */
DropShadow (Colour shadowColour, int radius, Point<int> offset) noexcept;
@ -56,10 +56,10 @@ struct JUCE_API DropShadow
In most cases you'll probably want to leave this as black with an alpha
value of around 0.5
*/
Colour colour;
Colour colour { 0x90000000 };
/** The approximate spread of the shadow. */
int radius;
int radius { 4 };
/** The offset of the shadow. */
Point<int> offset;

View file

@ -27,18 +27,6 @@
namespace juce
{
AffineTransform::AffineTransform() noexcept
: mat00 (1.0f), mat01 (0), mat02 (0),
mat10 (0), mat11 (1.0f), mat12 (0)
{
}
AffineTransform::AffineTransform (const AffineTransform& other) noexcept
: mat00 (other.mat00), mat01 (other.mat01), mat02 (other.mat02),
mat10 (other.mat10), mat11 (other.mat11), mat12 (other.mat12)
{
}
AffineTransform::AffineTransform (float m00, float m01, float m02,
float m10, float m11, float m12) noexcept
: mat00 (m00), mat01 (m01), mat02 (m02),
@ -46,18 +34,6 @@ AffineTransform::AffineTransform (float m00, float m01, float m02,
{
}
AffineTransform& AffineTransform::operator= (const AffineTransform& other) noexcept
{
mat00 = other.mat00;
mat01 = other.mat01;
mat02 = other.mat02;
mat10 = other.mat10;
mat11 = other.mat11;
mat12 = other.mat12;
return *this;
}
bool AffineTransform::operator== (const AffineTransform& other) const noexcept
{
return mat00 == other.mat00

View file

@ -45,10 +45,10 @@ class JUCE_API AffineTransform final
public:
//==============================================================================
/** Creates an identity transform. */
AffineTransform() noexcept;
AffineTransform() = default;
/** Creates a copy of another transform. */
AffineTransform (const AffineTransform& other) noexcept;
AffineTransform (const AffineTransform&) = default;
/** Creates a transform from a set of raw matrix values.
@ -62,7 +62,7 @@ public:
float mat10, float mat11, float mat12) noexcept;
/** Copies from another AffineTransform object */
AffineTransform& operator= (const AffineTransform& other) noexcept;
AffineTransform& operator= (const AffineTransform&) = default;
/** Compares two transforms. */
bool operator== (const AffineTransform& other) const noexcept;
@ -282,8 +282,8 @@ public:
(mat10 mat11 mat12)
( 0 0 1 )
*/
float mat00, mat01, mat02;
float mat10, mat11, mat12;
float mat00 { 1.0f }, mat01 { 0.0f }, mat02 { 0.0f };
float mat10 { 0.0f }, mat11 { 1.0f }, mat12 { 0.0f };
};
} // namespace juce

View file

@ -46,16 +46,10 @@ public:
/** Creates a null border.
All sizes are left as 0.
*/
BorderSize() noexcept
: top(), left(), bottom(), right()
{
}
BorderSize() = default;
/** Creates a copy of another border. */
BorderSize (const BorderSize& other) noexcept
: top (other.top), left (other.left), bottom (other.bottom), right (other.right)
{
}
BorderSize (const BorderSize&) = default;
/** Creates a border with the given gaps. */
BorderSize (ValueType topGap, ValueType leftGap, ValueType bottomGap, ValueType rightGap) noexcept
@ -149,7 +143,7 @@ public:
private:
//==============================================================================
ValueType top, left, bottom, right;
ValueType top{}, left{}, bottom{}, right{};
};
} // namespace juce

View file

@ -49,13 +49,10 @@ class Line
public:
//==============================================================================
/** Creates a line, using (0, 0) as its start and end points. */
Line() noexcept {}
Line() = default;
/** Creates a copy of another line. */
Line (const Line& other) noexcept
: start (other.start), end (other.end)
{
}
Line (const Line&) = default;
/** Creates a line based on the coordinates of its start and end points. */
Line (ValueType startX, ValueType startY, ValueType endX, ValueType endY) noexcept
@ -70,15 +67,10 @@ public:
}
/** Copies a line from another one. */
Line& operator= (const Line& other) noexcept
{
start = other.start;
end = other.end;
return *this;
}
Line& operator= (const Line&) = default;
/** Destructor. */
~Line() noexcept {}
~Line() = default;
//==============================================================================
/** Returns the x coordinate of the line's start point. */

View file

@ -41,15 +41,10 @@ public:
//==============================================================================
/** Creates a parallelogram with zero size at the origin.
*/
Parallelogram() noexcept
{
}
Parallelogram() = default;
/** Creates a copy of another parallelogram. */
Parallelogram (const Parallelogram& other) noexcept
: topLeft (other.topLeft), topRight (other.topRight), bottomLeft (other.bottomLeft)
{
}
Parallelogram (const Parallelogram&) = default;
/** Creates a parallelogram based on 3 points. */
Parallelogram (Point<ValueType> topLeftPosition,
@ -67,16 +62,10 @@ public:
{
}
Parallelogram& operator= (const Parallelogram& other) noexcept
{
topLeft = other.topLeft;
topRight = other.topRight;
bottomLeft = other.bottomLeft;
return *this;
}
Parallelogram& operator= (const Parallelogram&) = default;
/** Destructor. */
~Parallelogram() noexcept {}
~Parallelogram() = default;
//==============================================================================
/** Returns true if the parallelogram has a width or height of more than zero. */

View file

@ -46,14 +46,10 @@ public:
Justification (int justificationFlags) noexcept : flags (justificationFlags) {}
/** Creates a copy of another Justification object. */
Justification (const Justification& other) noexcept : flags (other.flags) {}
Justification (const Justification&) = default;
/** Copies another Justification object. */
Justification& operator= (const Justification& other) noexcept
{
flags = other.flags;
return *this;
}
Justification& operator= (const Justification&) = default;
bool operator== (const Justification& other) const noexcept { return flags == other.flags; }
bool operator!= (const Justification& other) const noexcept { return flags != other.flags; }

View file

@ -27,17 +27,6 @@
namespace juce
{
RectanglePlacement::RectanglePlacement (const RectanglePlacement& other) noexcept
: flags (other.flags)
{
}
RectanglePlacement& RectanglePlacement::operator= (const RectanglePlacement& other) noexcept
{
flags = other.flags;
return *this;
}
bool RectanglePlacement::operator== (const RectanglePlacement& other) const noexcept
{
return flags == other.flags;

View file

@ -45,13 +45,13 @@ public:
inline RectanglePlacement (int placementFlags) noexcept : flags (placementFlags) {}
/** Creates a default RectanglePlacement object, which is equivalent to using the 'centred' flag. */
inline RectanglePlacement() noexcept : flags (centred) {}
inline RectanglePlacement() = default;
/** Creates a copy of another RectanglePlacement object. */
RectanglePlacement (const RectanglePlacement&) noexcept;
RectanglePlacement (const RectanglePlacement&) = default;
/** Copies another RectanglePlacement object. */
RectanglePlacement& operator= (const RectanglePlacement&) noexcept;
RectanglePlacement& operator= (const RectanglePlacement&) = default;
bool operator== (const RectanglePlacement&) const noexcept;
bool operator!= (const RectanglePlacement&) const noexcept;
@ -169,7 +169,7 @@ public:
private:
//==============================================================================
int flags;
int flags { centred };
};
} // namespace juce