Skip to content

Commit

Permalink
attempt fixing compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Lo Giacco committed Jan 29, 2024
1 parent 4a45b09 commit aeb9b7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
3 changes: 1 addition & 2 deletions CircularBuffer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#include <CircularBuffer.hpp>

#pragma message("WARNING: please change import directive from CircularBiffer.h to CircularBuffer.hpp")
#include <CircularBuffer.hpp>
4 changes: 2 additions & 2 deletions CircularBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ template<typename T, size_t S, typename IT = typename Helper::Index<(S <= UINT8_
* @note No verification is done about the provided array length, it's the user responsibility to ensure the array provides enough space to accomodate
* all the elements currently stored in the buffer. After the function returns the elements in the buffer can be found starting at index 0 and up to the buffer size() at the moment of the copyToArray function call.
*/
void copyToArray(T* out) const;
void copyToArray(T* dest) const;

/**
* @brief Copies the buffer content into the provided array calling the provided conversion function for each and every element of the buffer.
Expand All @@ -186,7 +186,7 @@ template<typename T, size_t S, typename IT = typename Helper::Index<(S <= UINT8_
* @param convertFn the conversion function to call for each item stored in the buffer
*/
template<typename R>
void copyToArray(R* out, R (&convertFn)(const T&)) const;
void copyToArray(R* dest, R (&convertFn)(const T&)) const;

#ifdef CIRCULAR_BUFFER_DEBUG
void inline debug(Print* out);
Expand Down
24 changes: 12 additions & 12 deletions CircularBuffer.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,25 +124,25 @@ void inline CircularBuffer<T,S,IT>::clear() {
}

template<typename T, size_t S, typename IT>
void inline CircularBuffer<T,S,IT>::copyToArray(T* out) const {
const T* finish = out + count;
for (const T* current = head; current < (buffer + capacity) && out < finish; current++, out++) {
*out = *current;
void inline CircularBuffer<T,S,IT>::copyToArray(T* dest) const {
const T* finish = dest + count;
for (const T* current = head; current < (buffer + capacity) && dest < finish; current++, dest++) {
*dest = *current;
}
for (const T* current = buffer; current <= tail && out < finish; current++, out++) {
*out = *current;
for (const T* current = buffer; current <= tail && dest < finish; current++, dest++) {
*dest = *current;
}
}

template<typename T, size_t S, typename IT>
template<typename R>
void inline CircularBuffer<T,S,IT>::copyToArray(R* out, R (&convertFn)(const T&)) const {
const T* finish = out + count;
for (const T* current = head; current < (buffer + capacity) && out < finish; current++, out++) {
*out = convertFn(*current);
void inline CircularBuffer<T,S,IT>::copyToArray(R* dest, R (&convertFn)(const T&)) const {
const T* finish = dest + count;
for (const T* current = head; current < (buffer + capacity) && dest < finish; current++, dest++) {
*dest = convertFn(*current);
}
for (const T* current = buffer; current <= tail && out < finish; current++, out++) {
*out = convertFn(*current);
for (const T* current = buffer; current <= tail && dest < finish; current++, dest++) {
*dest = convertFn(*current);
}
}

Expand Down

0 comments on commit aeb9b7a

Please sign in to comment.