Changed the templates and loops to size_t in

AudioBuffer and AudioSpan
This commit is contained in:
Paul Ferrand 2020-01-05 10:09:25 +01:00
parent 391b2dc2e4
commit 2c2c31f542
2 changed files with 8 additions and 8 deletions

View file

@ -70,7 +70,7 @@ public:
: numChannels(numChannels) : numChannels(numChannels)
, numFrames(numFrames) , numFrames(numFrames)
{ {
for (auto i = 0; i < numChannels; ++i) for (size_t i = 0; i < numChannels; ++i)
buffers[i] = std::make_unique<buffer_type>(numFrames); buffers[i] = std::make_unique<buffer_type>(numFrames);
} }
@ -85,7 +85,7 @@ public:
{ {
bool returnedOK = true; bool returnedOK = true;
for (auto i = 0; i < numChannels; ++i) for (size_t i = 0; i < numChannels; ++i)
returnedOK &= buffers[i]->resize(newSize); returnedOK &= buffers[i]->resize(newSize);
if (returnedOK) if (returnedOK)

View file

@ -107,7 +107,7 @@ public:
, numChannels(numChannels) , numChannels(numChannels)
{ {
ASSERT(numChannels <= MaxChannels); ASSERT(numChannels <= MaxChannels);
for (auto i = 0; i < numChannels; ++i) for (size_t i = 0; i < numChannels; ++i)
this->spans[i] = spans[i] + offset; this->spans[i] = spans[i] + offset;
} }
@ -164,7 +164,7 @@ public:
* @tparam Alignment the alignment block size for the platform * @tparam Alignment the alignment block size for the platform
* @param audioBuffer the source AudioBuffer. * @param audioBuffer the source AudioBuffer.
*/ */
template <class U, int N, unsigned int Alignment, typename = std::enable_if<N <= MaxChannels>, typename = std::enable_if_t<std::is_const<U>::value, int>> template <class U, size_t N, unsigned int Alignment, typename = std::enable_if<N <= MaxChannels>, typename = std::enable_if_t<std::is_const<U>::value, int>>
AudioSpan(AudioBuffer<U, N, Alignment>& audioBuffer) AudioSpan(AudioBuffer<U, N, Alignment>& audioBuffer)
: numFrames(audioBuffer.getNumFrames()) : numFrames(audioBuffer.getNumFrames())
, numChannels(audioBuffer.getNumChannels()) , numChannels(audioBuffer.getNumChannels())
@ -185,7 +185,7 @@ public:
* @tparam Alignment the alignment block size for the platform * @tparam Alignment the alignment block size for the platform
* @param audioBuffer the source AudioBuffer. * @param audioBuffer the source AudioBuffer.
*/ */
template <class U, int N, unsigned int Alignment, typename = std::enable_if<N <= MaxChannels>> template <class U, size_t N, unsigned int Alignment, typename = std::enable_if<N <= MaxChannels>>
AudioSpan(AudioBuffer<U, N, Alignment>& audioBuffer) AudioSpan(AudioBuffer<U, N, Alignment>& audioBuffer)
: numFrames(audioBuffer.getNumFrames()) : numFrames(audioBuffer.getNumFrames())
, numChannels(audioBuffer.getNumChannels()) , numChannels(audioBuffer.getNumChannels())
@ -200,7 +200,7 @@ public:
* *
* @param other the other AudioSpan * @param other the other AudioSpan
*/ */
template <class U, int N, typename = std::enable_if<N <= MaxChannels>> template <class U, size_t N, typename = std::enable_if<N <= MaxChannels>>
AudioSpan(const AudioSpan<U, N>& other) AudioSpan(const AudioSpan<U, N>& other)
: numFrames(other.getNumFrames()) : numFrames(other.getNumFrames())
, numChannels(other.getNumChannels()) , numChannels(other.getNumChannels())
@ -312,7 +312,7 @@ public:
* *
* @param other the other AudioSpan * @param other the other AudioSpan
*/ */
template <class U, int N, typename = std::enable_if<N <= MaxChannels>> template <class U, size_t N, typename = std::enable_if<N <= MaxChannels>>
void add(AudioSpan<U, N>& other) void add(AudioSpan<U, N>& other)
{ {
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans"); static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
@ -329,7 +329,7 @@ public:
* *
* @param other the other AudioSpan * @param other the other AudioSpan
*/ */
template <class U, int N, typename = std::enable_if<N <= MaxChannels>> template <class U, size_t N, typename = std::enable_if<N <= MaxChannels>>
void copy(AudioSpan<U, N>& other) void copy(AudioSpan<U, N>& other)
{ {
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans"); static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");