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

Is there a reason you can only create HeapBlocks from int now?
Why is size_t or uint32_t etc. disabled?

Why not use std::is_integral_v<SizeType>?

Are you sure? This compiles fine for me: juce::HeapBlock<char> block { (size_t) 512 };

Ah sorry, I misread the code. It’s coming from an enum:

enum
{
    kFileBufferSize = 16384
};

juce::HeapBlock<char> block { kFileBufferSize };

Is what fails.

Thanks, I can reproduce that now. We should probably use std::is_enum to allow enumeration types as well then.

I think this is C++17, no?

Ah sorry, my bad. It’s just an alias for std::is_integral<SizeType>::value. Though looking at the docs it seems that doesn’t cover enums anyway. You’d also need to check std::is_enum<T>::value.

I’ve fixed this in my code now by casting it. enum support is probably less important than size_t (which always worked) but I wonder if there are others using enums for sizes? It’s a fairly common technique in older codebases.

Using std::is_enum will also allow enum class which we don’t really want. I’ve changed the code to use std::is_convertible which will allow integral values as well as anonymous enums:

Ok, thanks!