@@ -41,26 +41,23 @@ | |||||
#include "../../../Audio/MidiDemo.h" | #include "../../../Audio/MidiDemo.h" | ||||
#include "../../../Audio/MPEDemo.h" | #include "../../../Audio/MPEDemo.h" | ||||
#include "../../../Audio/PluckedStringsDemo.h" | #include "../../../Audio/PluckedStringsDemo.h" | ||||
#if JUCE_HAS_CONSTEXPR | |||||
#include "../../../Audio/SimpleFFTDemo.h" | |||||
#include "../../../BLOCKS/BlocksDrawingDemo.h" | |||||
#include "../../../BLOCKS/BlocksMonitorDemo.h" | |||||
#include "../../../BLOCKS/BlocksSynthDemo.h" | |||||
#include "../../../DSP/ConvolutionDemo.h" | |||||
#include "../../../DSP/FIRFilterDemo.h" | |||||
#include "../../../DSP/GainDemo.h" | |||||
#include "../../../DSP/IIRFilterDemo.h" | |||||
#include "../../../DSP/OscillatorDemo.h" | |||||
#include "../../../DSP/OverdriveDemo.h" | |||||
#if JUCE_USE_SIMD | |||||
#include "../../../DSP/SIMDRegisterDemo.h" | |||||
#endif | |||||
#include "../../../DSP/StateVariableFilterDemo.h" | |||||
#include "../../../DSP/WaveShaperTanhDemo.h" | |||||
#include "../../../Audio/SimpleFFTDemo.h" | |||||
#include "../../../BLOCKS/BlocksDrawingDemo.h" | |||||
#include "../../../BLOCKS/BlocksMonitorDemo.h" | |||||
#include "../../../BLOCKS/BlocksSynthDemo.h" | |||||
#include "../../../DSP/ConvolutionDemo.h" | |||||
#include "../../../DSP/FIRFilterDemo.h" | |||||
#include "../../../DSP/GainDemo.h" | |||||
#include "../../../DSP/IIRFilterDemo.h" | |||||
#include "../../../DSP/OscillatorDemo.h" | |||||
#include "../../../DSP/OverdriveDemo.h" | |||||
#if JUCE_USE_SIMD | |||||
#include "../../../DSP/SIMDRegisterDemo.h" | |||||
#endif | #endif | ||||
#include "../../../DSP/StateVariableFilterDemo.h" | |||||
#include "../../../DSP/WaveShaperTanhDemo.h" | |||||
#include "../../../Utilities/Box2DDemo.h" | #include "../../../Utilities/Box2DDemo.h" | ||||
#if JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX | #if JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX | ||||
@@ -90,7 +87,6 @@ void registerDemos_One() noexcept | |||||
REGISTER_DEMO (MPEDemo, Audio, false) | REGISTER_DEMO (MPEDemo, Audio, false) | ||||
REGISTER_DEMO (PluckedStringsDemo, Audio, false) | REGISTER_DEMO (PluckedStringsDemo, Audio, false) | ||||
#if JUCE_HAS_CONSTEXPR | |||||
REGISTER_DEMO (SimpleFFTDemo, Audio, false) | REGISTER_DEMO (SimpleFFTDemo, Audio, false) | ||||
REGISTER_DEMO (BlocksDrawingDemo, BLOCKS, false) | REGISTER_DEMO (BlocksDrawingDemo, BLOCKS, false) | ||||
REGISTER_DEMO (BlocksMonitorDemo, BLOCKS, false) | REGISTER_DEMO (BlocksMonitorDemo, BLOCKS, false) | ||||
@@ -107,7 +103,6 @@ void registerDemos_One() noexcept | |||||
#endif | #endif | ||||
REGISTER_DEMO (StateVariableFilterDemo, DSP, false) | REGISTER_DEMO (StateVariableFilterDemo, DSP, false) | ||||
REGISTER_DEMO (WaveShaperTanhDemo, DSP, false) | REGISTER_DEMO (WaveShaperTanhDemo, DSP, false) | ||||
#endif | |||||
REGISTER_DEMO (Box2DDemo, Utilities, false) | REGISTER_DEMO (Box2DDemo, Utilities, false) | ||||
#if JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX | #if JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX | ||||
@@ -46,9 +46,7 @@ | |||||
#include "../../../GUI/FlexBoxDemo.h" | #include "../../../GUI/FlexBoxDemo.h" | ||||
#include "../../../GUI/FontsDemo.h" | #include "../../../GUI/FontsDemo.h" | ||||
#include "../../../GUI/GraphicsDemo.h" | #include "../../../GUI/GraphicsDemo.h" | ||||
#if JUCE_HAS_CONSTEXPR | |||||
#include "../../../GUI/GridDemo.h" | |||||
#endif | |||||
#include "../../../GUI/GridDemo.h" | |||||
#include "../../../GUI/ImagesDemo.h" | #include "../../../GUI/ImagesDemo.h" | ||||
#include "../../../GUI/KeyMappingsDemo.h" | #include "../../../GUI/KeyMappingsDemo.h" | ||||
#include "../../../GUI/LookAndFeelDemo.h" | #include "../../../GUI/LookAndFeelDemo.h" | ||||
@@ -85,9 +83,7 @@ void registerDemos_Two() noexcept | |||||
REGISTER_DEMO (FlexBoxDemo, GUI, false) | REGISTER_DEMO (FlexBoxDemo, GUI, false) | ||||
REGISTER_DEMO (FontsDemo, GUI, false) | REGISTER_DEMO (FontsDemo, GUI, false) | ||||
REGISTER_DEMO (GraphicsDemo, GUI, false) | REGISTER_DEMO (GraphicsDemo, GUI, false) | ||||
#if JUCE_HAS_CONSTEXPR | |||||
REGISTER_DEMO (GridDemo, GUI, false) | REGISTER_DEMO (GridDemo, GUI, false) | ||||
#endif | |||||
REGISTER_DEMO (ImagesDemo, GUI, false) | REGISTER_DEMO (ImagesDemo, GUI, false) | ||||
REGISTER_DEMO (KeyMappingsDemo, GUI, false) | REGISTER_DEMO (KeyMappingsDemo, GUI, false) | ||||
REGISTER_DEMO (LookAndFeelDemo, GUI, false) | REGISTER_DEMO (LookAndFeelDemo, GUI, false) | ||||
@@ -1075,8 +1075,10 @@ private: | |||||
void allocateData() | void allocateData() | ||||
{ | { | ||||
#if (! JUCE_GCC) || (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 | |||||
static_assert (std::alignment_of<Type>::value <= std::alignment_of<std::max_align_t>::value, | static_assert (std::alignment_of<Type>::value <= std::alignment_of<std::max_align_t>::value, | ||||
"AudioBuffer cannot hold types with alignment requirements larger than that guaranteed by malloc"); | "AudioBuffer cannot hold types with alignment requirements larger than that guaranteed by malloc"); | ||||
#endif | |||||
jassert (size >= 0); | jassert (size >= 0); | ||||
auto channelListSize = (size_t) (numChannels + 1) * sizeof (Type*); | auto channelListSize = (size_t) (numChannels + 1) * sizeof (Type*); | ||||
@@ -157,8 +157,8 @@ const char* const WavAudioFormat::tracktionLoopInfo = "tracktion loop info"; | |||||
//============================================================================== | //============================================================================== | ||||
namespace WavFileHelpers | namespace WavFileHelpers | ||||
{ | { | ||||
JUCE_CONSTEXPR inline int chunkName (const char* name) noexcept { return (int) ByteOrder::littleEndianInt (name); } | |||||
JUCE_CONSTEXPR inline size_t roundUpSize (size_t sz) noexcept { return (sz + 3) & ~3u; } | |||||
constexpr inline int chunkName (const char* name) noexcept { return (int) ByteOrder::littleEndianInt (name); } | |||||
constexpr inline size_t roundUpSize (size_t sz) noexcept { return (sz + 3) & ~3u; } | |||||
#if JUCE_MSVC | #if JUCE_MSVC | ||||
#pragma pack (push, 1) | #pragma pack (push, 1) | ||||
@@ -22,12 +22,6 @@ | |||||
#include "juce_blocks_basics.h" | #include "juce_blocks_basics.h" | ||||
#if ! JUCE_HAS_CONSTEXPR | |||||
#ifndef JUCE_DEMO_RUNNER | |||||
#error "The juce_blocks_basics module requires a compiler that supports constexpr" | |||||
#endif | |||||
#else | |||||
#include <regex> | #include <regex> | ||||
namespace juce | namespace juce | ||||
@@ -48,5 +42,3 @@ namespace juce | |||||
#include "topology/juce_RuleBasedTopologySource.cpp" | #include "topology/juce_RuleBasedTopologySource.cpp" | ||||
#include "visualisers/juce_DrumPadLEDProgram.cpp" | #include "visualisers/juce_DrumPadLEDProgram.cpp" | ||||
#include "visualisers/juce_BitmapLEDProgram.cpp" | #include "visualisers/juce_BitmapLEDProgram.cpp" | ||||
#endif |
@@ -52,12 +52,6 @@ | |||||
#include <juce_events/juce_events.h> | #include <juce_events/juce_events.h> | ||||
#include <juce_audio_devices/juce_audio_devices.h> | #include <juce_audio_devices/juce_audio_devices.h> | ||||
#if ! JUCE_HAS_CONSTEXPR | |||||
#ifndef JUCE_DEMO_RUNNER | |||||
#error "The juce_blocks_basics module requires a compiler that supports constexpr" | |||||
#endif | |||||
#else | |||||
namespace juce | namespace juce | ||||
{ | { | ||||
class TouchSurface; | class TouchSurface; | ||||
@@ -89,5 +83,3 @@ namespace juce | |||||
#include "littlefoot/juce_LittleFootRunner.h" | #include "littlefoot/juce_LittleFootRunner.h" | ||||
#include "littlefoot/juce_LittleFootCompiler.h" | #include "littlefoot/juce_LittleFootCompiler.h" | ||||
} | } | ||||
#endif |
@@ -91,33 +91,33 @@ using uint32 = unsigned int; | |||||
/** Returns the larger of two values. */ | /** Returns the larger of two values. */ | ||||
template <typename Type> | template <typename Type> | ||||
JUCE_CONSTEXPR Type jmax (Type a, Type b) { return a < b ? b : a; } | |||||
constexpr Type jmax (Type a, Type b) { return a < b ? b : a; } | |||||
/** Returns the larger of three values. */ | /** Returns the larger of three values. */ | ||||
template <typename Type> | template <typename Type> | ||||
JUCE_CONSTEXPR Type jmax (Type a, Type b, Type c) { return a < b ? (b < c ? c : b) : (a < c ? c : a); } | |||||
constexpr Type jmax (Type a, Type b, Type c) { return a < b ? (b < c ? c : b) : (a < c ? c : a); } | |||||
/** Returns the larger of four values. */ | /** Returns the larger of four values. */ | ||||
template <typename Type> | template <typename Type> | ||||
JUCE_CONSTEXPR Type jmax (Type a, Type b, Type c, Type d) { return jmax (a, jmax (b, c, d)); } | |||||
constexpr Type jmax (Type a, Type b, Type c, Type d) { return jmax (a, jmax (b, c, d)); } | |||||
/** Returns the smaller of two values. */ | /** Returns the smaller of two values. */ | ||||
template <typename Type> | template <typename Type> | ||||
JUCE_CONSTEXPR Type jmin (Type a, Type b) { return b < a ? b : a; } | |||||
constexpr Type jmin (Type a, Type b) { return b < a ? b : a; } | |||||
/** Returns the smaller of three values. */ | /** Returns the smaller of three values. */ | ||||
template <typename Type> | template <typename Type> | ||||
JUCE_CONSTEXPR Type jmin (Type a, Type b, Type c) { return b < a ? (c < b ? c : b) : (c < a ? c : a); } | |||||
constexpr Type jmin (Type a, Type b, Type c) { return b < a ? (c < b ? c : b) : (c < a ? c : a); } | |||||
/** Returns the smaller of four values. */ | /** Returns the smaller of four values. */ | ||||
template <typename Type> | template <typename Type> | ||||
JUCE_CONSTEXPR Type jmin (Type a, Type b, Type c, Type d) { return jmin (a, jmin (b, c, d)); } | |||||
constexpr Type jmin (Type a, Type b, Type c, Type d) { return jmin (a, jmin (b, c, d)); } | |||||
/** Remaps a normalised value (between 0 and 1) to a target range. | /** Remaps a normalised value (between 0 and 1) to a target range. | ||||
This effectively returns (targetRangeMin + value0To1 * (targetRangeMax - targetRangeMin)). | This effectively returns (targetRangeMin + value0To1 * (targetRangeMax - targetRangeMin)). | ||||
*/ | */ | ||||
template <typename Type> | template <typename Type> | ||||
JUCE_CONSTEXPR Type jmap (Type value0To1, Type targetRangeMin, Type targetRangeMax) | |||||
constexpr Type jmap (Type value0To1, Type targetRangeMin, Type targetRangeMax) | |||||
{ | { | ||||
return targetRangeMin + value0To1 * (targetRangeMax - targetRangeMin); | return targetRangeMin + value0To1 * (targetRangeMax - targetRangeMin); | ||||
} | } | ||||
@@ -297,7 +297,7 @@ void ignoreUnused (Types&&...) noexcept {} | |||||
@endcode | @endcode | ||||
*/ | */ | ||||
template <typename Type, size_t N> | template <typename Type, size_t N> | ||||
JUCE_CONSTEXPR int numElementsInArray (Type (&)[N]) noexcept { return N; } | |||||
constexpr int numElementsInArray (Type (&)[N]) noexcept { return N; } | |||||
//============================================================================== | //============================================================================== | ||||
// Some useful maths functions that aren't always present with all compilers and build settings. | // Some useful maths functions that aren't always present with all compilers and build settings. | ||||
@@ -327,8 +327,6 @@ inline float juce_hypot (float a, float b) noexcept | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
#if JUCE_HAS_CONSTEXPR | |||||
/** Commonly used mathematical constants | /** Commonly used mathematical constants | ||||
@tags{Core} | @tags{Core} | ||||
@@ -352,71 +350,29 @@ struct MathConstants | |||||
static constexpr FloatType sqrt2 = static_cast<FloatType> (1.4142135623730950488L); | static constexpr FloatType sqrt2 = static_cast<FloatType> (1.4142135623730950488L); | ||||
}; | }; | ||||
#else | |||||
/** Commonly used mathematical constants | |||||
@tags{Core} | |||||
*/ | |||||
template <typename FloatType> | |||||
struct MathConstants | |||||
{ | |||||
/** A predefined value for Pi */ | |||||
static const FloatType pi; | |||||
/** A predefined value for 2 * Pi */ | |||||
static const FloatType twoPi; | |||||
/** A predefined value for Pi / 2 */ | |||||
static const FloatType halfPi; | |||||
/** A predefined value for Euler's number */ | |||||
static const FloatType euler; | |||||
/** A predefined value for sqrt(2) */ | |||||
static const FloatType sqrt2; | |||||
}; | |||||
template <typename FloatType> | |||||
const FloatType MathConstants<FloatType>::pi = static_cast<FloatType> (3.141592653589793238L); | |||||
template <typename FloatType> | |||||
const FloatType MathConstants<FloatType>::twoPi = static_cast<FloatType> (2 * 3.141592653589793238L); | |||||
template <typename FloatType> | |||||
const FloatType MathConstants<FloatType>::halfPi = static_cast<FloatType> (3.141592653589793238L / 2); | |||||
template <typename FloatType> | |||||
const FloatType MathConstants<FloatType>::euler = static_cast<FloatType> (2.71828182845904523536L); | |||||
template <typename FloatType> | |||||
const FloatType MathConstants<FloatType>::sqrt2 = static_cast<FloatType> (1.4142135623730950488L); | |||||
#endif | |||||
#ifndef DOXYGEN | #ifndef DOXYGEN | ||||
/** A double-precision constant for pi. | /** A double-precision constant for pi. | ||||
@deprecated This is deprecated in favour of MathConstants<double>::pi. | @deprecated This is deprecated in favour of MathConstants<double>::pi. | ||||
The reason is that "double_Pi" was a confusing name, and many people misused it, | The reason is that "double_Pi" was a confusing name, and many people misused it, | ||||
wrongly thinking it meant 2 * pi ! | wrongly thinking it meant 2 * pi ! | ||||
*/ | */ | ||||
const JUCE_CONSTEXPR double double_Pi = MathConstants<double>::pi; | |||||
const constexpr double double_Pi = MathConstants<double>::pi; | |||||
/** A single-precision constant for pi. | /** A single-precision constant for pi. | ||||
@deprecated This is deprecated in favour of MathConstants<float>::pi. | @deprecated This is deprecated in favour of MathConstants<float>::pi. | ||||
The reason is that "double_Pi" was a confusing name, and many people misused it, | The reason is that "double_Pi" was a confusing name, and many people misused it, | ||||
wrongly thinking it meant 2 * pi ! | wrongly thinking it meant 2 * pi ! | ||||
*/ | */ | ||||
const JUCE_CONSTEXPR float float_Pi = MathConstants<float>::pi; | |||||
const constexpr float float_Pi = MathConstants<float>::pi; | |||||
#endif | #endif | ||||
/** Converts an angle in degrees to radians. */ | /** Converts an angle in degrees to radians. */ | ||||
template <typename FloatType> | template <typename FloatType> | ||||
JUCE_CONSTEXPR FloatType degreesToRadians (FloatType degrees) noexcept { return degrees * (MathConstants<FloatType>::pi / FloatType (180)); } | |||||
constexpr FloatType degreesToRadians (FloatType degrees) noexcept { return degrees * (MathConstants<FloatType>::pi / FloatType (180)); } | |||||
/** Converts an angle in radians to degrees. */ | /** Converts an angle in radians to degrees. */ | ||||
template <typename FloatType> | template <typename FloatType> | ||||
JUCE_CONSTEXPR FloatType radiansToDegrees (FloatType radians) noexcept { return radians * (FloatType (180) / MathConstants<FloatType>::pi); } | |||||
constexpr FloatType radiansToDegrees (FloatType radians) noexcept { return radians * (FloatType (180) / MathConstants<FloatType>::pi); } | |||||
//============================================================================== | //============================================================================== | ||||
@@ -529,7 +485,7 @@ unsigned int truncatePositiveToUnsignedInt (FloatType value) noexcept | |||||
//============================================================================== | //============================================================================== | ||||
/** Returns true if the specified integer is a power-of-two. */ | /** Returns true if the specified integer is a power-of-two. */ | ||||
template <typename IntegerType> | template <typename IntegerType> | ||||
JUCE_CONSTEXPR bool isPowerOfTwo (IntegerType value) | |||||
constexpr bool isPowerOfTwo (IntegerType value) | |||||
{ | { | ||||
return (value & (value - 1)) == 0; | return (value & (value - 1)) == 0; | ||||
} | } | ||||
@@ -582,7 +538,7 @@ IntegerType negativeAwareModulo (IntegerType dividend, const IntegerType divisor | |||||
/** Returns the square of its argument. */ | /** Returns the square of its argument. */ | ||||
template <typename NumericType> | template <typename NumericType> | ||||
inline JUCE_CONSTEXPR NumericType square (NumericType n) noexcept | |||||
inline constexpr NumericType square (NumericType n) noexcept | |||||
{ | { | ||||
return n * n; | return n * n; | ||||
} | } | ||||
@@ -41,22 +41,22 @@ class Range | |||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
/** Constructs an empty range. */ | /** Constructs an empty range. */ | ||||
JUCE_CONSTEXPR Range() = default; | |||||
constexpr Range() = default; | |||||
/** Constructs a range with given start and end values. */ | /** Constructs a range with given start and end values. */ | ||||
JUCE_CONSTEXPR Range (const ValueType startValue, const ValueType endValue) noexcept | |||||
constexpr Range (const ValueType startValue, const ValueType endValue) noexcept | |||||
: start (startValue), end (jmax (startValue, endValue)) | : start (startValue), end (jmax (startValue, endValue)) | ||||
{ | { | ||||
} | } | ||||
/** Constructs a copy of another range. */ | /** Constructs a copy of another range. */ | ||||
JUCE_CONSTEXPR Range (const Range&) = default; | |||||
constexpr Range (const Range&) = default; | |||||
/** Copies another range object. */ | /** Copies another range object. */ | ||||
Range& operator= (const Range&) = default; | Range& operator= (const Range&) = default; | ||||
/** Returns the range that lies between two positions (in either order). */ | /** Returns the range that lies between two positions (in either order). */ | ||||
JUCE_CONSTEXPR static Range between (const ValueType position1, const ValueType position2) noexcept | |||||
constexpr static Range between (const ValueType position1, const ValueType position2) noexcept | |||||
{ | { | ||||
return position1 < position2 ? Range (position1, position2) | return position1 < position2 ? Range (position1, position2) | ||||
: Range (position2, position1); | : Range (position2, position1); | ||||
@@ -70,23 +70,23 @@ public: | |||||
} | } | ||||
/** Returns a range with the specified start position and a length of zero. */ | /** Returns a range with the specified start position and a length of zero. */ | ||||
JUCE_CONSTEXPR static Range emptyRange (const ValueType start) noexcept | |||||
constexpr static Range emptyRange (const ValueType start) noexcept | |||||
{ | { | ||||
return Range (start, start); | return Range (start, start); | ||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
/** Returns the start of the range. */ | /** Returns the start of the range. */ | ||||
JUCE_CONSTEXPR inline ValueType getStart() const noexcept { return start; } | |||||
constexpr inline ValueType getStart() const noexcept { return start; } | |||||
/** Returns the length of the range. */ | /** Returns the length of the range. */ | ||||
JUCE_CONSTEXPR inline ValueType getLength() const noexcept { return end - start; } | |||||
constexpr inline ValueType getLength() const noexcept { return end - start; } | |||||
/** Returns the end of the range. */ | /** Returns the end of the range. */ | ||||
JUCE_CONSTEXPR inline ValueType getEnd() const noexcept { return end; } | |||||
constexpr inline ValueType getEnd() const noexcept { return end; } | |||||
/** Returns true if the range has a length of zero. */ | /** Returns true if the range has a length of zero. */ | ||||
JUCE_CONSTEXPR inline bool isEmpty() const noexcept { return start == end; } | |||||
constexpr inline bool isEmpty() const noexcept { return start == end; } | |||||
//============================================================================== | //============================================================================== | ||||
/** Changes the start position of the range, leaving the end position unchanged. | /** Changes the start position of the range, leaving the end position unchanged. | ||||
@@ -104,13 +104,13 @@ public: | |||||
If the new start position is higher than the current end of the range, the end point | If the new start position is higher than the current end of the range, the end point | ||||
will be pushed along to equal it, returning an empty range at the new position. | will be pushed along to equal it, returning an empty range at the new position. | ||||
*/ | */ | ||||
JUCE_CONSTEXPR Range withStart (const ValueType newStart) const noexcept | |||||
constexpr Range withStart (const ValueType newStart) const noexcept | |||||
{ | { | ||||
return Range (newStart, jmax (newStart, end)); | return Range (newStart, jmax (newStart, end)); | ||||
} | } | ||||
/** Returns a range with the same length as this one, but moved to have the given start position. */ | /** Returns a range with the same length as this one, but moved to have the given start position. */ | ||||
JUCE_CONSTEXPR Range movedToStartAt (const ValueType newStart) const noexcept | |||||
constexpr Range movedToStartAt (const ValueType newStart) const noexcept | |||||
{ | { | ||||
return Range (newStart, end + (newStart - start)); | return Range (newStart, end + (newStart - start)); | ||||
} | } | ||||
@@ -130,13 +130,13 @@ public: | |||||
If the new end position is below the current start of the range, the start point | If the new end position is below the current start of the range, the start point | ||||
will be pushed back to equal the new end point. | will be pushed back to equal the new end point. | ||||
*/ | */ | ||||
JUCE_CONSTEXPR Range withEnd (const ValueType newEnd) const noexcept | |||||
constexpr Range withEnd (const ValueType newEnd) const noexcept | |||||
{ | { | ||||
return Range (jmin (start, newEnd), newEnd); | return Range (jmin (start, newEnd), newEnd); | ||||
} | } | ||||
/** Returns a range with the same length as this one, but moved to have the given end position. */ | /** Returns a range with the same length as this one, but moved to have the given end position. */ | ||||
JUCE_CONSTEXPR Range movedToEndAt (const ValueType newEnd) const noexcept | |||||
constexpr Range movedToEndAt (const ValueType newEnd) const noexcept | |||||
{ | { | ||||
return Range (start + (newEnd - end), newEnd); | return Range (start + (newEnd - end), newEnd); | ||||
} | } | ||||
@@ -152,7 +152,7 @@ public: | |||||
/** Returns a range with the same start as this one, but a different length. | /** Returns a range with the same start as this one, but a different length. | ||||
Lengths less than zero are treated as zero. | Lengths less than zero are treated as zero. | ||||
*/ | */ | ||||
JUCE_CONSTEXPR Range withLength (const ValueType newLength) const noexcept | |||||
constexpr Range withLength (const ValueType newLength) const noexcept | |||||
{ | { | ||||
return Range (start, start + newLength); | return Range (start, start + newLength); | ||||
} | } | ||||
@@ -161,7 +161,7 @@ public: | |||||
given amount. | given amount. | ||||
@returns The returned range will be (start - amount, end + amount) | @returns The returned range will be (start - amount, end + amount) | ||||
*/ | */ | ||||
JUCE_CONSTEXPR Range expanded (ValueType amount) const noexcept | |||||
constexpr Range expanded (ValueType amount) const noexcept | |||||
{ | { | ||||
return Range (start - amount, end + amount); | return Range (start - amount, end + amount); | ||||
} | } | ||||
@@ -186,27 +186,27 @@ public: | |||||
/** Returns a range that is equal to this one with an amount added to its | /** Returns a range that is equal to this one with an amount added to its | ||||
start and end. | start and end. | ||||
*/ | */ | ||||
JUCE_CONSTEXPR Range operator+ (const ValueType amountToAdd) const noexcept | |||||
constexpr Range operator+ (const ValueType amountToAdd) const noexcept | |||||
{ | { | ||||
return Range (start + amountToAdd, end + amountToAdd); | return Range (start + amountToAdd, end + amountToAdd); | ||||
} | } | ||||
/** Returns a range that is equal to this one with the specified amount | /** Returns a range that is equal to this one with the specified amount | ||||
subtracted from its start and end. */ | subtracted from its start and end. */ | ||||
JUCE_CONSTEXPR Range operator- (const ValueType amountToSubtract) const noexcept | |||||
constexpr Range operator- (const ValueType amountToSubtract) const noexcept | |||||
{ | { | ||||
return Range (start - amountToSubtract, end - amountToSubtract); | return Range (start - amountToSubtract, end - amountToSubtract); | ||||
} | } | ||||
JUCE_CONSTEXPR bool operator== (Range other) const noexcept { return start == other.start && end == other.end; } | |||||
JUCE_CONSTEXPR bool operator!= (Range other) const noexcept { return start != other.start || end != other.end; } | |||||
constexpr bool operator== (Range other) const noexcept { return start == other.start && end == other.end; } | |||||
constexpr bool operator!= (Range other) const noexcept { return start != other.start || end != other.end; } | |||||
//============================================================================== | //============================================================================== | ||||
/** Returns true if the given position lies inside this range. | /** Returns true if the given position lies inside this range. | ||||
When making this comparison, the start value is considered to be inclusive, | When making this comparison, the start value is considered to be inclusive, | ||||
and the end of the range exclusive. | and the end of the range exclusive. | ||||
*/ | */ | ||||
JUCE_CONSTEXPR bool contains (const ValueType position) const noexcept | |||||
constexpr bool contains (const ValueType position) const noexcept | |||||
{ | { | ||||
return start <= position && position < end; | return start <= position && position < end; | ||||
} | } | ||||
@@ -218,34 +218,34 @@ public: | |||||
} | } | ||||
/** Returns true if the given range lies entirely inside this range. */ | /** Returns true if the given range lies entirely inside this range. */ | ||||
JUCE_CONSTEXPR bool contains (Range other) const noexcept | |||||
constexpr bool contains (Range other) const noexcept | |||||
{ | { | ||||
return start <= other.start && end >= other.end; | return start <= other.start && end >= other.end; | ||||
} | } | ||||
/** Returns true if the given range intersects this one. */ | /** Returns true if the given range intersects this one. */ | ||||
JUCE_CONSTEXPR bool intersects (Range other) const noexcept | |||||
constexpr bool intersects (Range other) const noexcept | |||||
{ | { | ||||
return other.start < end && start < other.end; | return other.start < end && start < other.end; | ||||
} | } | ||||
/** Returns the range that is the intersection of the two ranges, or an empty range | /** Returns the range that is the intersection of the two ranges, or an empty range | ||||
with an undefined start position if they don't overlap. */ | with an undefined start position if they don't overlap. */ | ||||
JUCE_CONSTEXPR Range getIntersectionWith (Range other) const noexcept | |||||
constexpr Range getIntersectionWith (Range other) const noexcept | |||||
{ | { | ||||
return Range (jmax (start, other.start), | return Range (jmax (start, other.start), | ||||
jmin (end, other.end)); | jmin (end, other.end)); | ||||
} | } | ||||
/** Returns the smallest range that contains both this one and the other one. */ | /** Returns the smallest range that contains both this one and the other one. */ | ||||
JUCE_CONSTEXPR Range getUnionWith (Range other) const noexcept | |||||
constexpr Range getUnionWith (Range other) const noexcept | |||||
{ | { | ||||
return Range (jmin (start, other.start), | return Range (jmin (start, other.start), | ||||
jmax (end, other.end)); | jmax (end, other.end)); | ||||
} | } | ||||
/** Returns the smallest range that contains both this one and the given value. */ | /** Returns the smallest range that contains both this one and the given value. */ | ||||
JUCE_CONSTEXPR Range getUnionWith (const ValueType valueToInclude) const noexcept | |||||
constexpr Range getUnionWith (const ValueType valueToInclude) const noexcept | |||||
{ | { | ||||
return Range (jmin (valueToInclude, start), | return Range (jmin (valueToInclude, start), | ||||
jmax (valueToInclude, end)); | jmax (valueToInclude, end)); | ||||
@@ -34,10 +34,10 @@ class JUCE_API ByteOrder | |||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
/** Swaps the upper and lower bytes of a 16-bit integer. */ | /** Swaps the upper and lower bytes of a 16-bit integer. */ | ||||
JUCE_CONSTEXPR static uint16 swap (uint16 value) noexcept; | |||||
constexpr static uint16 swap (uint16 value) noexcept; | |||||
/** Swaps the upper and lower bytes of a 16-bit integer. */ | /** Swaps the upper and lower bytes of a 16-bit integer. */ | ||||
JUCE_CONSTEXPR static int16 swap (int16 value) noexcept; | |||||
constexpr static int16 swap (int16 value) noexcept; | |||||
/** Reverses the order of the 4 bytes in a 32-bit integer. */ | /** Reverses the order of the 4 bytes in a 32-bit integer. */ | ||||
static uint32 swap (uint32 value) noexcept; | static uint32 swap (uint32 value) noexcept; | ||||
@@ -82,50 +82,50 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
/** Turns 4 bytes into a little-endian integer. */ | /** Turns 4 bytes into a little-endian integer. */ | ||||
JUCE_CONSTEXPR static uint32 littleEndianInt (const void* bytes) noexcept; | |||||
constexpr static uint32 littleEndianInt (const void* bytes) noexcept; | |||||
/** Turns 8 bytes into a little-endian integer. */ | /** Turns 8 bytes into a little-endian integer. */ | ||||
JUCE_CONSTEXPR static uint64 littleEndianInt64 (const void* bytes) noexcept; | |||||
constexpr static uint64 littleEndianInt64 (const void* bytes) noexcept; | |||||
/** Turns 2 bytes into a little-endian integer. */ | /** Turns 2 bytes into a little-endian integer. */ | ||||
JUCE_CONSTEXPR static uint16 littleEndianShort (const void* bytes) noexcept; | |||||
constexpr static uint16 littleEndianShort (const void* bytes) noexcept; | |||||
/** Converts 3 little-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */ | /** Converts 3 little-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */ | ||||
JUCE_CONSTEXPR static int littleEndian24Bit (const void* bytes) noexcept; | |||||
constexpr static int littleEndian24Bit (const void* bytes) noexcept; | |||||
/** Copies a 24-bit number to 3 little-endian bytes. */ | /** Copies a 24-bit number to 3 little-endian bytes. */ | ||||
static void littleEndian24BitToChars (int32 value, void* destBytes) noexcept; | static void littleEndian24BitToChars (int32 value, void* destBytes) noexcept; | ||||
//============================================================================== | //============================================================================== | ||||
/** Turns 4 bytes into a big-endian integer. */ | /** Turns 4 bytes into a big-endian integer. */ | ||||
JUCE_CONSTEXPR static uint32 bigEndianInt (const void* bytes) noexcept; | |||||
constexpr static uint32 bigEndianInt (const void* bytes) noexcept; | |||||
/** Turns 8 bytes into a big-endian integer. */ | /** Turns 8 bytes into a big-endian integer. */ | ||||
JUCE_CONSTEXPR static uint64 bigEndianInt64 (const void* bytes) noexcept; | |||||
constexpr static uint64 bigEndianInt64 (const void* bytes) noexcept; | |||||
/** Turns 2 bytes into a big-endian integer. */ | /** Turns 2 bytes into a big-endian integer. */ | ||||
JUCE_CONSTEXPR static uint16 bigEndianShort (const void* bytes) noexcept; | |||||
constexpr static uint16 bigEndianShort (const void* bytes) noexcept; | |||||
/** Converts 3 big-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */ | /** Converts 3 big-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */ | ||||
JUCE_CONSTEXPR static int bigEndian24Bit (const void* bytes) noexcept; | |||||
constexpr static int bigEndian24Bit (const void* bytes) noexcept; | |||||
/** Copies a 24-bit number to 3 big-endian bytes. */ | /** Copies a 24-bit number to 3 big-endian bytes. */ | ||||
static void bigEndian24BitToChars (int32 value, void* destBytes) noexcept; | static void bigEndian24BitToChars (int32 value, void* destBytes) noexcept; | ||||
//============================================================================== | //============================================================================== | ||||
/** Constructs a 16-bit integer from its constituent bytes, in order of significance. */ | /** Constructs a 16-bit integer from its constituent bytes, in order of significance. */ | ||||
JUCE_CONSTEXPR static uint16 makeInt (uint8 leastSig, uint8 mostSig) noexcept; | |||||
constexpr static uint16 makeInt (uint8 leastSig, uint8 mostSig) noexcept; | |||||
/** Constructs a 32-bit integer from its constituent bytes, in order of significance. */ | /** Constructs a 32-bit integer from its constituent bytes, in order of significance. */ | ||||
JUCE_CONSTEXPR static uint32 makeInt (uint8 leastSig, uint8 byte1, uint8 byte2, uint8 mostSig) noexcept; | |||||
constexpr static uint32 makeInt (uint8 leastSig, uint8 byte1, uint8 byte2, uint8 mostSig) noexcept; | |||||
/** Constructs a 64-bit integer from its constituent bytes, in order of significance. */ | /** Constructs a 64-bit integer from its constituent bytes, in order of significance. */ | ||||
JUCE_CONSTEXPR static uint64 makeInt (uint8 leastSig, uint8 byte1, uint8 byte2, uint8 byte3, | |||||
uint8 byte4, uint8 byte5, uint8 byte6, uint8 mostSig) noexcept; | |||||
constexpr static uint64 makeInt (uint8 leastSig, uint8 byte1, uint8 byte2, uint8 byte3, | |||||
uint8 byte4, uint8 byte5, uint8 byte6, uint8 mostSig) noexcept; | |||||
//============================================================================== | //============================================================================== | ||||
/** Returns true if the current CPU is big-endian. */ | /** Returns true if the current CPU is big-endian. */ | ||||
JUCE_CONSTEXPR static bool isBigEndian() noexcept | |||||
constexpr static bool isBigEndian() noexcept | |||||
{ | { | ||||
#if JUCE_LITTLE_ENDIAN | #if JUCE_LITTLE_ENDIAN | ||||
return false; | return false; | ||||
@@ -140,8 +140,8 @@ private: | |||||
//============================================================================== | //============================================================================== | ||||
JUCE_CONSTEXPR inline uint16 ByteOrder::swap (uint16 v) noexcept { return static_cast<uint16> ((v << 8) | (v >> 8)); } | |||||
JUCE_CONSTEXPR inline int16 ByteOrder::swap (int16 v) noexcept { return static_cast<int16> (swap (static_cast<uint16> (v))); } | |||||
constexpr inline uint16 ByteOrder::swap (uint16 v) noexcept { return static_cast<uint16> ((v << 8) | (v >> 8)); } | |||||
constexpr inline int16 ByteOrder::swap (int16 v) noexcept { return static_cast<int16> (swap (static_cast<uint16> (v))); } | |||||
inline int32 ByteOrder::swap (int32 v) noexcept { return static_cast<int32> (swap (static_cast<uint32> (v))); } | inline int32 ByteOrder::swap (int32 v) noexcept { return static_cast<int32> (swap (static_cast<uint32> (v))); } | ||||
inline int64 ByteOrder::swap (int64 v) noexcept { return static_cast<int64> (swap (static_cast<uint64> (v))); } | inline int64 ByteOrder::swap (int64 v) noexcept { return static_cast<int64> (swap (static_cast<uint64> (v))); } | ||||
inline float ByteOrder::swap (float v) noexcept { union { uint32 asUInt; float asFloat; } n; n.asFloat = v; n.asUInt = swap (n.asUInt); return n.asFloat; } | inline float ByteOrder::swap (float v) noexcept { union { uint32 asUInt; float asFloat; } n; n.asFloat = v; n.asUInt = swap (n.asUInt); return n.asFloat; } | ||||
@@ -178,41 +178,41 @@ inline uint64 ByteOrder::swap (uint64 value) noexcept | |||||
#endif | #endif | ||||
} | } | ||||
JUCE_CONSTEXPR inline uint16 ByteOrder::makeInt (uint8 b0, uint8 b1) noexcept | |||||
constexpr inline uint16 ByteOrder::makeInt (uint8 b0, uint8 b1) noexcept | |||||
{ | { | ||||
return static_cast<uint16> (static_cast<uint16> (b0) | (static_cast<uint16> (b1) << 8)); | return static_cast<uint16> (static_cast<uint16> (b0) | (static_cast<uint16> (b1) << 8)); | ||||
} | } | ||||
JUCE_CONSTEXPR inline uint32 ByteOrder::makeInt (uint8 b0, uint8 b1, uint8 b2, uint8 b3) noexcept | |||||
constexpr inline uint32 ByteOrder::makeInt (uint8 b0, uint8 b1, uint8 b2, uint8 b3) noexcept | |||||
{ | { | ||||
return static_cast<uint32> (b0) | (static_cast<uint32> (b1) << 8) | return static_cast<uint32> (b0) | (static_cast<uint32> (b1) << 8) | ||||
| (static_cast<uint32> (b2) << 16) | (static_cast<uint32> (b3) << 24); | | (static_cast<uint32> (b2) << 16) | (static_cast<uint32> (b3) << 24); | ||||
} | } | ||||
JUCE_CONSTEXPR inline uint64 ByteOrder::makeInt (uint8 b0, uint8 b1, uint8 b2, uint8 b3, uint8 b4, uint8 b5, uint8 b6, uint8 b7) noexcept | |||||
constexpr inline uint64 ByteOrder::makeInt (uint8 b0, uint8 b1, uint8 b2, uint8 b3, uint8 b4, uint8 b5, uint8 b6, uint8 b7) noexcept | |||||
{ | { | ||||
return static_cast<uint64> (b0) | (static_cast<uint64> (b1) << 8) | (static_cast<uint64> (b2) << 16) | (static_cast<uint64> (b3) << 24) | return static_cast<uint64> (b0) | (static_cast<uint64> (b1) << 8) | (static_cast<uint64> (b2) << 16) | (static_cast<uint64> (b3) << 24) | ||||
| (static_cast<uint64> (b4) << 32) | (static_cast<uint64> (b5) << 40) | (static_cast<uint64> (b6) << 48) | (static_cast<uint64> (b7) << 56); | | (static_cast<uint64> (b4) << 32) | (static_cast<uint64> (b5) << 40) | (static_cast<uint64> (b6) << 48) | (static_cast<uint64> (b7) << 56); | ||||
} | } | ||||
JUCE_CONSTEXPR inline uint16 ByteOrder::littleEndianShort (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[0], static_cast<const uint8*> (bytes)[1]); } | |||||
JUCE_CONSTEXPR inline uint32 ByteOrder::littleEndianInt (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[0], static_cast<const uint8*> (bytes)[1], | |||||
constexpr inline uint16 ByteOrder::littleEndianShort (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[0], static_cast<const uint8*> (bytes)[1]); } | |||||
constexpr inline uint32 ByteOrder::littleEndianInt (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[0], static_cast<const uint8*> (bytes)[1], | |||||
static_cast<const uint8*> (bytes)[2], static_cast<const uint8*> (bytes)[3]); } | static_cast<const uint8*> (bytes)[2], static_cast<const uint8*> (bytes)[3]); } | ||||
JUCE_CONSTEXPR inline uint64 ByteOrder::littleEndianInt64 (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[0], static_cast<const uint8*> (bytes)[1], | |||||
constexpr inline uint64 ByteOrder::littleEndianInt64 (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[0], static_cast<const uint8*> (bytes)[1], | |||||
static_cast<const uint8*> (bytes)[2], static_cast<const uint8*> (bytes)[3], | static_cast<const uint8*> (bytes)[2], static_cast<const uint8*> (bytes)[3], | ||||
static_cast<const uint8*> (bytes)[4], static_cast<const uint8*> (bytes)[5], | static_cast<const uint8*> (bytes)[4], static_cast<const uint8*> (bytes)[5], | ||||
static_cast<const uint8*> (bytes)[6], static_cast<const uint8*> (bytes)[7]); } | static_cast<const uint8*> (bytes)[6], static_cast<const uint8*> (bytes)[7]); } | ||||
JUCE_CONSTEXPR inline uint16 ByteOrder::bigEndianShort (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[1], static_cast<const uint8*> (bytes)[0]); } | |||||
JUCE_CONSTEXPR inline uint32 ByteOrder::bigEndianInt (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[3], static_cast<const uint8*> (bytes)[2], | |||||
constexpr inline uint16 ByteOrder::bigEndianShort (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[1], static_cast<const uint8*> (bytes)[0]); } | |||||
constexpr inline uint32 ByteOrder::bigEndianInt (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[3], static_cast<const uint8*> (bytes)[2], | |||||
static_cast<const uint8*> (bytes)[1], static_cast<const uint8*> (bytes)[0]); } | static_cast<const uint8*> (bytes)[1], static_cast<const uint8*> (bytes)[0]); } | ||||
JUCE_CONSTEXPR inline uint64 ByteOrder::bigEndianInt64 (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[7], static_cast<const uint8*> (bytes)[6], | |||||
constexpr inline uint64 ByteOrder::bigEndianInt64 (const void* bytes) noexcept { return makeInt (static_cast<const uint8*> (bytes)[7], static_cast<const uint8*> (bytes)[6], | |||||
static_cast<const uint8*> (bytes)[5], static_cast<const uint8*> (bytes)[4], | static_cast<const uint8*> (bytes)[5], static_cast<const uint8*> (bytes)[4], | ||||
static_cast<const uint8*> (bytes)[3], static_cast<const uint8*> (bytes)[2], | static_cast<const uint8*> (bytes)[3], static_cast<const uint8*> (bytes)[2], | ||||
static_cast<const uint8*> (bytes)[1], static_cast<const uint8*> (bytes)[0]); } | static_cast<const uint8*> (bytes)[1], static_cast<const uint8*> (bytes)[0]); } | ||||
JUCE_CONSTEXPR inline int32 ByteOrder::littleEndian24Bit (const void* bytes) noexcept { return (int32) ((((uint32) static_cast<const int8*> (bytes)[2]) << 16) | (((uint32) static_cast<const uint8*> (bytes)[1]) << 8) | ((uint32) static_cast<const uint8*> (bytes)[0])); } | |||||
JUCE_CONSTEXPR inline int32 ByteOrder::bigEndian24Bit (const void* bytes) noexcept { return (int32) ((((uint32) static_cast<const int8*> (bytes)[0]) << 16) | (((uint32) static_cast<const uint8*> (bytes)[1]) << 8) | ((uint32) static_cast<const uint8*> (bytes)[2])); } | |||||
constexpr inline int32 ByteOrder::littleEndian24Bit (const void* bytes) noexcept { return (int32) ((((uint32) static_cast<const int8*> (bytes)[2]) << 16) | (((uint32) static_cast<const uint8*> (bytes)[1]) << 8) | ((uint32) static_cast<const uint8*> (bytes)[0])); } | |||||
constexpr inline int32 ByteOrder::bigEndian24Bit (const void* bytes) noexcept { return (int32) ((((uint32) static_cast<const int8*> (bytes)[0]) << 16) | (((uint32) static_cast<const uint8*> (bytes)[1]) << 8) | ((uint32) static_cast<const uint8*> (bytes)[2])); } | |||||
inline void ByteOrder::littleEndian24BitToChars (int32 value, void* destBytes) noexcept { static_cast<uint8*> (destBytes)[0] = (uint8) value; static_cast<uint8*> (destBytes)[1] = (uint8) (value >> 8); static_cast<uint8*> (destBytes)[2] = (uint8) (value >> 16); } | inline void ByteOrder::littleEndian24BitToChars (int32 value, void* destBytes) noexcept { static_cast<uint8*> (destBytes)[0] = (uint8) value; static_cast<uint8*> (destBytes)[1] = (uint8) (value >> 8); static_cast<uint8*> (destBytes)[2] = (uint8) (value >> 16); } | ||||
inline void ByteOrder::bigEndian24BitToChars (int32 value, void* destBytes) noexcept { static_cast<uint8*> (destBytes)[0] = (uint8) (value >> 16); static_cast<uint8*> (destBytes)[1] = (uint8) (value >> 8); static_cast<uint8*> (destBytes)[2] = (uint8) value; } | inline void ByteOrder::bigEndian24BitToChars (int32 value, void* destBytes) noexcept { static_cast<uint8*> (destBytes)[0] = (uint8) (value >> 16); static_cast<uint8*> (destBytes)[1] = (uint8) (value >> 8); static_cast<uint8*> (destBytes)[2] = (uint8) value; } | ||||
@@ -38,10 +38,6 @@ | |||||
#error "JUCE requires that GCC has C++11 compatibility enabled" | #error "JUCE requires that GCC has C++11 compatibility enabled" | ||||
#endif | #endif | ||||
#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 | |||||
#define JUCE_HAS_CONSTEXPR 1 | |||||
#endif | |||||
#ifndef JUCE_EXCEPTIONS_DISABLED | #ifndef JUCE_EXCEPTIONS_DISABLED | ||||
#if ! __EXCEPTIONS | #if ! __EXCEPTIONS | ||||
#define JUCE_EXCEPTIONS_DISABLED 1 | #define JUCE_EXCEPTIONS_DISABLED 1 | ||||
@@ -61,8 +57,6 @@ | |||||
#error "JUCE requires Clang 3.3 or later" | #error "JUCE requires Clang 3.3 or later" | ||||
#endif | #endif | ||||
#define JUCE_HAS_CONSTEXPR 1 | |||||
#ifndef JUCE_COMPILER_SUPPORTS_ARC | #ifndef JUCE_COMPILER_SUPPORTS_ARC | ||||
#define JUCE_COMPILER_SUPPORTS_ARC 1 | #define JUCE_COMPILER_SUPPORTS_ARC 1 | ||||
#endif | #endif | ||||
@@ -86,8 +80,6 @@ | |||||
#error "JUCE requires Visual Studio 2015 or later" | #error "JUCE requires Visual Studio 2015 or later" | ||||
#endif | #endif | ||||
#define JUCE_HAS_CONSTEXPR 1 | |||||
#ifndef JUCE_EXCEPTIONS_DISABLED | #ifndef JUCE_EXCEPTIONS_DISABLED | ||||
#if ! _CPPUNWIND | #if ! _CPPUNWIND | ||||
#define JUCE_EXCEPTIONS_DISABLED 1 | #define JUCE_EXCEPTIONS_DISABLED 1 | ||||
@@ -105,12 +97,6 @@ | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
#if JUCE_HAS_CONSTEXPR | |||||
#define JUCE_CONSTEXPR constexpr | |||||
#else | |||||
#define JUCE_CONSTEXPR | |||||
#endif | |||||
#if (! JUCE_MSVC) && (! JUCE_CXX14_IS_AVAILABLE) | #if (! JUCE_MSVC) && (! JUCE_CXX14_IS_AVAILABLE) | ||||
namespace std | namespace std | ||||
{ | { | ||||
@@ -122,6 +108,7 @@ namespace std | |||||
} | } | ||||
#endif | #endif | ||||
//============================================================================== | |||||
#if ! DOXYGEN | #if ! DOXYGEN | ||||
// These are old flags that are now supported on all compatible build targets | // These are old flags that are now supported on all compatible build targets | ||||
#define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 | #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 | ||||
@@ -129,4 +116,5 @@ namespace std | |||||
#define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1 | #define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1 | ||||
#define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 | #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 | ||||
#define JUCE_DELETED_FUNCTION = delete | #define JUCE_DELETED_FUNCTION = delete | ||||
#define JUCE_CONSTEXPR constexpr | |||||
#endif | #endif |
@@ -149,8 +149,8 @@ public: | |||||
#if JUCE_MINGW | #if JUCE_MINGW | ||||
bool isNegative = false; | bool isNegative = false; | ||||
#else | #else | ||||
JUCE_CONSTEXPR const int maxSignificantDigits = 17 + 1; // An additional digit for rounding | |||||
JUCE_CONSTEXPR const int bufferSize = maxSignificantDigits + 7 + 1; // -.E-XXX and a trailing null-terminator | |||||
constexpr const int maxSignificantDigits = 17 + 1; // An additional digit for rounding | |||||
constexpr const int bufferSize = maxSignificantDigits + 7 + 1; // -.E-XXX and a trailing null-terminator | |||||
char buffer[(size_t) bufferSize] = {}; | char buffer[(size_t) bufferSize] = {}; | ||||
char* currentCharacter = &(buffer[0]); | char* currentCharacter = &(buffer[0]); | ||||
#endif | #endif | ||||
@@ -200,7 +200,7 @@ public: | |||||
int exponent = 0, decPointIndex = 0, digit = 0; | int exponent = 0, decPointIndex = 0, digit = 0; | ||||
int lastDigit = 0, numSignificantDigits = 0; | int lastDigit = 0, numSignificantDigits = 0; | ||||
bool digitsFound = false; | bool digitsFound = false; | ||||
JUCE_CONSTEXPR const int maxSignificantDigits = 17 + 1; | |||||
constexpr const int maxSignificantDigits = 17 + 1; | |||||
for (;;) | for (;;) | ||||
{ | { | ||||
@@ -29,13 +29,13 @@ namespace juce | |||||
namespace PropertyFileConstants | namespace PropertyFileConstants | ||||
{ | { | ||||
JUCE_CONSTEXPR static const int magicNumber = (int) ByteOrder::makeInt ('P', 'R', 'O', 'P'); | |||||
JUCE_CONSTEXPR static const int magicNumberCompressed = (int) ByteOrder::makeInt ('C', 'P', 'R', 'P'); | |||||
constexpr static const int magicNumber = (int) ByteOrder::makeInt ('P', 'R', 'O', 'P'); | |||||
constexpr static const int magicNumberCompressed = (int) ByteOrder::makeInt ('C', 'P', 'R', 'P'); | |||||
JUCE_CONSTEXPR static const char* const fileTag = "PROPERTIES"; | |||||
JUCE_CONSTEXPR static const char* const valueTag = "VALUE"; | |||||
JUCE_CONSTEXPR static const char* const nameAttribute = "name"; | |||||
JUCE_CONSTEXPR static const char* const valueAttribute = "val"; | |||||
constexpr static const char* const fileTag = "PROPERTIES"; | |||||
constexpr static const char* const valueTag = "VALUE"; | |||||
constexpr static const char* const nameAttribute = "name"; | |||||
constexpr static const char* const valueAttribute = "val"; | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -35,12 +35,6 @@ | |||||
#include "juce_dsp.h" | #include "juce_dsp.h" | ||||
#if ! JUCE_HAS_CONSTEXPR | |||||
#ifndef JUCE_DEMO_RUNNER | |||||
#error "The juce_dsp module requires a compiler that supports constexpr" | |||||
#endif | |||||
#else | |||||
#ifndef JUCE_USE_VDSP_FRAMEWORK | #ifndef JUCE_USE_VDSP_FRAMEWORK | ||||
#define JUCE_USE_VDSP_FRAMEWORK 1 | #define JUCE_USE_VDSP_FRAMEWORK 1 | ||||
#endif | #endif | ||||
@@ -93,5 +87,3 @@ | |||||
#include "frequency/juce_FFT_test.cpp" | #include "frequency/juce_FFT_test.cpp" | ||||
#include "processors/juce_FIRFilter_test.cpp" | #include "processors/juce_FIRFilter_test.cpp" | ||||
#endif | #endif | ||||
#endif |
@@ -59,12 +59,6 @@ | |||||
#include <juce_audio_basics/juce_audio_basics.h> | #include <juce_audio_basics/juce_audio_basics.h> | ||||
#include <juce_audio_formats/juce_audio_formats.h> | #include <juce_audio_formats/juce_audio_formats.h> | ||||
#if ! JUCE_HAS_CONSTEXPR | |||||
#ifndef JUCE_DEMO_RUNNER | |||||
#error "The juce_dsp module requires a compiler that supports constexpr" | |||||
#endif | |||||
#else | |||||
#if defined(_M_X64) || defined(__amd64__) || defined(__SSE2__) || (defined(_M_IX86_FP) && _M_IX86_FP == 2) | #if defined(_M_X64) || defined(__amd64__) || defined(__SSE2__) || (defined(_M_IX86_FP) && _M_IX86_FP == 2) | ||||
#if defined(_M_X64) || defined(__amd64__) | #if defined(_M_X64) || defined(__amd64__) | ||||
@@ -271,5 +265,3 @@ namespace juce | |||||
#include "frequency/juce_Convolution.h" | #include "frequency/juce_Convolution.h" | ||||
#include "frequency/juce_Windowing.h" | #include "frequency/juce_Windowing.h" | ||||
#include "filter_design/juce_FilterDesign.h" | #include "filter_design/juce_FilterDesign.h" | ||||
#endif |
@@ -43,101 +43,101 @@ class Point | |||||
{ | { | ||||
public: | public: | ||||
/** Creates a point at the origin */ | /** Creates a point at the origin */ | ||||
JUCE_CONSTEXPR Point() = default; | |||||
constexpr Point() = default; | |||||
/** Creates a copy of another point. */ | /** Creates a copy of another point. */ | ||||
JUCE_CONSTEXPR Point (const Point&) = default; | |||||
constexpr Point (const Point&) = default; | |||||
/** Creates a point from an (x, y) position. */ | /** Creates a point from an (x, y) position. */ | ||||
JUCE_CONSTEXPR Point (ValueType initialX, ValueType initialY) noexcept : x (initialX), y (initialY) {} | |||||
constexpr Point (ValueType initialX, ValueType initialY) noexcept : x (initialX), y (initialY) {} | |||||
//============================================================================== | //============================================================================== | ||||
/** Copies this point from another one. */ | /** Copies this point from another one. */ | ||||
Point& operator= (const Point&) = default; | Point& operator= (const Point&) = default; | ||||
JUCE_CONSTEXPR inline bool operator== (Point other) const noexcept { return x == other.x && y == other.y; } | |||||
JUCE_CONSTEXPR inline bool operator!= (Point other) const noexcept { return x != other.x || y != other.y; } | |||||
constexpr inline bool operator== (Point other) const noexcept { return x == other.x && y == other.y; } | |||||
constexpr inline bool operator!= (Point other) const noexcept { return x != other.x || y != other.y; } | |||||
/** Returns true if the point is (0, 0). */ | /** Returns true if the point is (0, 0). */ | ||||
JUCE_CONSTEXPR bool isOrigin() const noexcept { return x == ValueType() && y == ValueType(); } | |||||
constexpr bool isOrigin() const noexcept { return x == ValueType() && y == ValueType(); } | |||||
/** Returns true if the coordinates are finite values. */ | /** Returns true if the coordinates are finite values. */ | ||||
JUCE_CONSTEXPR inline bool isFinite() const noexcept { return juce_isfinite(x) && juce_isfinite(y); } | |||||
constexpr inline bool isFinite() const noexcept { return juce_isfinite(x) && juce_isfinite(y); } | |||||
/** Returns the point's x coordinate. */ | /** Returns the point's x coordinate. */ | ||||
JUCE_CONSTEXPR inline ValueType getX() const noexcept { return x; } | |||||
constexpr inline ValueType getX() const noexcept { return x; } | |||||
/** Returns the point's y coordinate. */ | /** Returns the point's y coordinate. */ | ||||
JUCE_CONSTEXPR inline ValueType getY() const noexcept { return y; } | |||||
constexpr inline ValueType getY() const noexcept { return y; } | |||||
/** Sets the point's x coordinate. */ | /** Sets the point's x coordinate. */ | ||||
inline void setX (ValueType newX) noexcept { x = newX; } | |||||
inline void setX (ValueType newX) noexcept { x = newX; } | |||||
/** Sets the point's y coordinate. */ | /** Sets the point's y coordinate. */ | ||||
inline void setY (ValueType newY) noexcept { y = newY; } | |||||
inline void setY (ValueType newY) noexcept { y = newY; } | |||||
/** Returns a point which has the same Y position as this one, but a new X. */ | /** Returns a point which has the same Y position as this one, but a new X. */ | ||||
JUCE_CONSTEXPR Point withX (ValueType newX) const noexcept { return Point (newX, y); } | |||||
constexpr Point withX (ValueType newX) const noexcept { return Point (newX, y); } | |||||
/** Returns a point which has the same X position as this one, but a new Y. */ | /** Returns a point which has the same X position as this one, but a new Y. */ | ||||
JUCE_CONSTEXPR Point withY (ValueType newY) const noexcept { return Point (x, newY); } | |||||
constexpr Point withY (ValueType newY) const noexcept { return Point (x, newY); } | |||||
/** Changes the point's x and y coordinates. */ | /** Changes the point's x and y coordinates. */ | ||||
void setXY (ValueType newX, ValueType newY) noexcept { x = newX; y = newY; } | |||||
void setXY (ValueType newX, ValueType newY) noexcept { x = newX; y = newY; } | |||||
/** Adds a pair of coordinates to this value. */ | /** Adds a pair of coordinates to this value. */ | ||||
void addXY (ValueType xToAdd, ValueType yToAdd) noexcept { x += xToAdd; y += yToAdd; } | |||||
void addXY (ValueType xToAdd, ValueType yToAdd) noexcept { x += xToAdd; y += yToAdd; } | |||||
//============================================================================== | //============================================================================== | ||||
/** Returns a point with a given offset from this one. */ | /** Returns a point with a given offset from this one. */ | ||||
JUCE_CONSTEXPR Point translated (ValueType deltaX, ValueType deltaY) const noexcept { return Point (x + deltaX, y + deltaY); } | |||||
constexpr Point translated (ValueType deltaX, ValueType deltaY) const noexcept { return Point (x + deltaX, y + deltaY); } | |||||
/** Adds two points together */ | /** Adds two points together */ | ||||
JUCE_CONSTEXPR Point operator+ (Point other) const noexcept { return Point (x + other.x, y + other.y); } | |||||
constexpr Point operator+ (Point other) const noexcept { return Point (x + other.x, y + other.y); } | |||||
/** Adds another point's coordinates to this one */ | /** Adds another point's coordinates to this one */ | ||||
Point& operator+= (Point other) noexcept { x += other.x; y += other.y; return *this; } | |||||
Point& operator+= (Point other) noexcept { x += other.x; y += other.y; return *this; } | |||||
/** Subtracts one points from another */ | /** Subtracts one points from another */ | ||||
JUCE_CONSTEXPR Point operator- (Point other) const noexcept { return Point (x - other.x, y - other.y); } | |||||
constexpr Point operator- (Point other) const noexcept { return Point (x - other.x, y - other.y); } | |||||
/** Subtracts another point's coordinates to this one */ | /** Subtracts another point's coordinates to this one */ | ||||
Point& operator-= (Point other) noexcept { x -= other.x; y -= other.y; return *this; } | |||||
Point& operator-= (Point other) noexcept { x -= other.x; y -= other.y; return *this; } | |||||
/** Multiplies two points together */ | /** Multiplies two points together */ | ||||
template <typename OtherType> | template <typename OtherType> | ||||
JUCE_CONSTEXPR Point operator* (Point<OtherType> other) const noexcept { return Point ((ValueType) (x * other.x), (ValueType) (y * other.y)); } | |||||
constexpr Point operator* (Point<OtherType> other) const noexcept { return Point ((ValueType) (x * other.x), (ValueType) (y * other.y)); } | |||||
/** Multiplies another point's coordinates to this one */ | /** Multiplies another point's coordinates to this one */ | ||||
template <typename OtherType> | template <typename OtherType> | ||||
Point& operator*= (Point<OtherType> other) noexcept { *this = *this * other; return *this; } | |||||
Point& operator*= (Point<OtherType> other) noexcept { *this = *this * other; return *this; } | |||||
/** Divides one point by another */ | /** Divides one point by another */ | ||||
template <typename OtherType> | template <typename OtherType> | ||||
JUCE_CONSTEXPR Point operator/ (Point<OtherType> other) const noexcept { return Point ((ValueType) (x / other.x), (ValueType) (y / other.y)); } | |||||
constexpr Point operator/ (Point<OtherType> other) const noexcept { return Point ((ValueType) (x / other.x), (ValueType) (y / other.y)); } | |||||
/** Divides this point's coordinates by another */ | /** Divides this point's coordinates by another */ | ||||
template <typename OtherType> | template <typename OtherType> | ||||
Point& operator/= (Point<OtherType> other) noexcept { *this = *this / other; return *this; } | |||||
Point& operator/= (Point<OtherType> other) noexcept { *this = *this / other; return *this; } | |||||
/** Returns a point whose coordinates are multiplied by a given scalar value. */ | /** Returns a point whose coordinates are multiplied by a given scalar value. */ | ||||
template <typename FloatType> | template <typename FloatType> | ||||
JUCE_CONSTEXPR Point operator* (FloatType multiplier) const noexcept { return Point ((ValueType) (x * multiplier), (ValueType) (y * multiplier)); } | |||||
constexpr Point operator* (FloatType multiplier) const noexcept { return Point ((ValueType) (x * multiplier), (ValueType) (y * multiplier)); } | |||||
/** Returns a point whose coordinates are divided by a given scalar value. */ | /** Returns a point whose coordinates are divided by a given scalar value. */ | ||||
template <typename FloatType> | template <typename FloatType> | ||||
JUCE_CONSTEXPR Point operator/ (FloatType divisor) const noexcept { return Point ((ValueType) (x / divisor), (ValueType) (y / divisor)); } | |||||
constexpr Point operator/ (FloatType divisor) const noexcept { return Point ((ValueType) (x / divisor), (ValueType) (y / divisor)); } | |||||
/** Multiplies the point's coordinates by a scalar value. */ | /** Multiplies the point's coordinates by a scalar value. */ | ||||
template <typename FloatType> | template <typename FloatType> | ||||
Point& operator*= (FloatType multiplier) noexcept { x = (ValueType) (x * multiplier); y = (ValueType) (y * multiplier); return *this; } | |||||
Point& operator*= (FloatType multiplier) noexcept { x = (ValueType) (x * multiplier); y = (ValueType) (y * multiplier); return *this; } | |||||
/** Divides the point's coordinates by a scalar value. */ | /** Divides the point's coordinates by a scalar value. */ | ||||
template <typename FloatType> | template <typename FloatType> | ||||
Point& operator/= (FloatType divisor) noexcept { x = (ValueType) (x / divisor); y = (ValueType) (y / divisor); return *this; } | |||||
Point& operator/= (FloatType divisor) noexcept { x = (ValueType) (x / divisor); y = (ValueType) (y / divisor); return *this; } | |||||
/** Returns the inverse of this point. */ | /** Returns the inverse of this point. */ | ||||
JUCE_CONSTEXPR Point operator-() const noexcept { return Point (-x, -y); } | |||||
constexpr Point operator-() const noexcept { return Point (-x, -y); } | |||||
//============================================================================== | //============================================================================== | ||||
/** This type will be double if the Point's type is double, otherwise it will be float. */ | /** This type will be double if the Point's type is double, otherwise it will be float. */ | ||||
@@ -145,16 +145,16 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
/** Returns the straight-line distance between this point and the origin. */ | /** Returns the straight-line distance between this point and the origin. */ | ||||
ValueType getDistanceFromOrigin() const noexcept { return juce_hypot (x, y); } | |||||
ValueType getDistanceFromOrigin() const noexcept { return juce_hypot (x, y); } | |||||
/** Returns the straight-line distance between this point and another one. */ | /** Returns the straight-line distance between this point and another one. */ | ||||
ValueType getDistanceFrom (Point other) const noexcept { return juce_hypot (x - other.x, y - other.y); } | |||||
ValueType getDistanceFrom (Point other) const noexcept { return juce_hypot (x - other.x, y - other.y); } | |||||
/** Returns the square of the straight-line distance between this point and the origin. */ | /** Returns the square of the straight-line distance between this point and the origin. */ | ||||
JUCE_CONSTEXPR ValueType getDistanceSquaredFromOrigin() const noexcept { return x * x + y * y; } | |||||
constexpr ValueType getDistanceSquaredFromOrigin() const noexcept { return x * x + y * y; } | |||||
/** Returns the square of the straight-line distance between this point and another one. */ | /** Returns the square of the straight-line distance between this point and another one. */ | ||||
JUCE_CONSTEXPR ValueType getDistanceSquaredFrom (Point other) const noexcept { return (*this - other).getDistanceSquaredFromOrigin(); } | |||||
constexpr ValueType getDistanceSquaredFrom (Point other) const noexcept { return (*this - other).getDistanceSquaredFromOrigin(); } | |||||
/** Returns the angle from this point to another one. | /** Returns the angle from this point to another one. | ||||
@@ -200,7 +200,7 @@ public: | |||||
} | } | ||||
/** Returns the dot-product of two points (x1 * x2 + y1 * y2). */ | /** Returns the dot-product of two points (x1 * x2 + y1 * y2). */ | ||||
JUCE_CONSTEXPR FloatType getDotProduct (Point other) const noexcept { return x * other.x + y * other.y; } | |||||
constexpr FloatType getDotProduct (Point other) const noexcept { return x * other.x + y * other.y; } | |||||
//============================================================================== | //============================================================================== | ||||
/** Uses a transform to change the point's coordinates. | /** Uses a transform to change the point's coordinates. | ||||
@@ -219,16 +219,16 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
/** Casts this point to a Point<int> object. */ | /** Casts this point to a Point<int> object. */ | ||||
JUCE_CONSTEXPR Point<int> toInt() const noexcept { return Point<int> (static_cast<int> (x), static_cast<int> (y)); } | |||||
constexpr Point<int> toInt() const noexcept { return Point<int> (static_cast<int> (x), static_cast<int> (y)); } | |||||
/** Casts this point to a Point<float> object. */ | /** Casts this point to a Point<float> object. */ | ||||
JUCE_CONSTEXPR Point<float> toFloat() const noexcept { return Point<float> (static_cast<float> (x), static_cast<float> (y)); } | |||||
constexpr Point<float> toFloat() const noexcept { return Point<float> (static_cast<float> (x), static_cast<float> (y)); } | |||||
/** Casts this point to a Point<double> object. */ | /** Casts this point to a Point<double> object. */ | ||||
JUCE_CONSTEXPR Point<double> toDouble() const noexcept { return Point<double> (static_cast<double> (x), static_cast<double> (y)); } | |||||
constexpr Point<double> toDouble() const noexcept { return Point<double> (static_cast<double> (x), static_cast<double> (y)); } | |||||
/** Casts this point to a Point<int> object using roundToInt() to convert the values. */ | /** Casts this point to a Point<int> object using roundToInt() to convert the values. */ | ||||
JUCE_CONSTEXPR Point<int> roundToInt() const noexcept { return Point<int> (juce::roundToInt (x), juce::roundToInt (y)); } | |||||
constexpr Point<int> roundToInt() const noexcept { return Point<int> (juce::roundToInt (x), juce::roundToInt (y)); } | |||||
/** Returns the point as a string in the form "x, y". */ | /** Returns the point as a string in the form "x, y". */ | ||||
String toString() const { return String (x) + ", " + String (y); } | String toString() const { return String (x) + ", " + String (y); } | ||||
@@ -263,10 +263,8 @@ namespace juce | |||||
#include "misc/juce_JUCESplashScreen.cpp" | #include "misc/juce_JUCESplashScreen.cpp" | ||||
#include "layout/juce_FlexBox.cpp" | #include "layout/juce_FlexBox.cpp" | ||||
#if JUCE_HAS_CONSTEXPR | |||||
#include "layout/juce_GridItem.cpp" | |||||
#include "layout/juce_Grid.cpp" | |||||
#endif | |||||
#include "layout/juce_GridItem.cpp" | |||||
#include "layout/juce_Grid.cpp" | |||||
#if JUCE_IOS || JUCE_WINDOWS | #if JUCE_IOS || JUCE_WINDOWS | ||||
#include "native/juce_MultiTouchMapper.h" | #include "native/juce_MultiTouchMapper.h" | ||||
@@ -159,9 +159,7 @@ namespace juce | |||||
class Displays; | class Displays; | ||||
class FlexBox; | class FlexBox; | ||||
#if JUCE_HAS_CONSTEXPR | |||||
class Grid; | |||||
#endif | |||||
class Grid; | |||||
} | } | ||||
#include "mouse/juce_MouseCursor.h" | #include "mouse/juce_MouseCursor.h" | ||||
@@ -305,7 +303,5 @@ namespace juce | |||||
#include "layout/juce_FlexItem.h" | #include "layout/juce_FlexItem.h" | ||||
#include "layout/juce_FlexBox.h" | #include "layout/juce_FlexBox.h" | ||||
#if JUCE_HAS_CONSTEXPR | |||||
#include "layout/juce_GridItem.h" | |||||
#include "layout/juce_Grid.h" | |||||
#endif | |||||
#include "layout/juce_GridItem.h" | |||||
#include "layout/juce_Grid.h" |