Browse Source

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

v6.1.6
reuk 4 years ago
parent
commit
e02a09da0c
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      modules/juce_core/memory/juce_HeapBlock.h

+ 2
- 2
modules/juce_core/memory/juce_HeapBlock.h View File

@@ -107,7 +107,7 @@ public:
If you want an array of zero values, you can use the calloc() method or the If you want an array of zero values, you can use the calloc() method or the
other constructor that takes an InitialisationState parameter. 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) explicit HeapBlock (SizeType numElements)
: data (static_cast<ElementType*> (std::malloc (static_cast<size_t> (numElements) * sizeof (ElementType)))) : 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, The initialiseToZero parameter determines whether the new memory should be cleared,
or left uninitialised. 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) HeapBlock (SizeType numElements, bool initialiseToZero)
: data (static_cast<ElementType*> (initialiseToZero : data (static_cast<ElementType*> (initialiseToZero
? std::calloc (static_cast<size_t> (numElements), sizeof (ElementType)) ? std::calloc (static_cast<size_t> (numElements), sizeof (ElementType))


Loading…
Cancel
Save