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

HeapBlock: Disable size-based constructor for non-integral arguments

This commit is contained in:
reuk 2021-08-18 17:00:36 +01:00
parent ef0b1ec1ef
commit e02a09da0c
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -107,7 +107,7 @@ public:
If you want an array of zero values, you can use the calloc() method or the
other constructor that takes an InitialisationState parameter.
*/
template <typename SizeType>
template <typename SizeType, std::enable_if_t<std::is_integral<SizeType>::value, int> = 0>
explicit HeapBlock (SizeType numElements)
: data (static_cast<ElementType*> (std::malloc (static_cast<size_t> (numElements) * sizeof (ElementType))))
{
@ -119,7 +119,7 @@ public:
The initialiseToZero parameter determines whether the new memory should be cleared,
or left uninitialised.
*/
template <typename SizeType>
template <typename SizeType, std::enable_if_t<std::is_integral<SizeType>::value, int> = 0>
HeapBlock (SizeType numElements, bool initialiseToZero)
: data (static_cast<ElementType*> (initialiseToZero
? std::calloc (static_cast<size_t> (numElements), sizeof (ElementType))