1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

MathsFunctions: Made numElementsInArray constexpr

This commit is contained in:
reuk 2019-03-19 13:56:22 +00:00 committed by Tom Poole
parent a8ff4ea180
commit e5ce2ceb97

View file

@ -297,12 +297,7 @@ void ignoreUnused (Types&&...) noexcept {}
@endcode
*/
template <typename Type, int N>
int numElementsInArray (Type (&array)[N])
{
(void) array;
(void) sizeof (0[array]); // This line should cause an error if you pass an object with a user-defined subscript operator
return N;
}
JUCE_CONSTEXPR int numElementsInArray (Type (&)[N]) noexcept { return N; }
//==============================================================================
// Some useful maths functions that aren't always present with all compilers and build settings.