Skip to content

Commit

Permalink
Fix build warnings/errors in C++20
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Sep 20, 2024
1 parent 3cb6f28 commit 950fc35
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Sming/Components/FlashString
2 changes: 1 addition & 1 deletion Sming/Components/Storage/src/include/Storage/Partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class Partition
bool read(storage_size_t offset, void* dst, size_t size);

template <typename T>
typename std::enable_if<std::is_pod<T>::value, bool>::type read(storage_size_t offset, T& value)
typename std::enable_if<std::is_standard_layout<T>::value, bool>::type read(storage_size_t offset, T& value)
{
return read(offset, &value, sizeof(value));
}
Expand Down
20 changes: 10 additions & 10 deletions Sming/Wiring/FIFO.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

#include "Countable.h"

template <typename T, int rawSize> class FIFO : public Countable<T>
template <typename T, unsigned rawSize> class FIFO : public Countable<T>
{
public:
const int size; // speculative feature, in case it's needed
const unsigned size; // speculative feature, in case it's needed

FIFO();

Expand Down Expand Up @@ -60,18 +60,18 @@ template <typename T, int rawSize> class FIFO : public Countable<T>
}

protected:
volatile int numberOfElements;
int nextIn;
int nextOut;
unsigned numberOfElements;
unsigned nextIn;
unsigned nextOut;
T raw[rawSize];
};

template <typename T, int rawSize> FIFO<T, rawSize>::FIFO() : size(rawSize)
template <typename T, unsigned rawSize> FIFO<T, rawSize>::FIFO() : size(rawSize)
{
flush();
}

template <typename T, int rawSize> bool FIFO<T, rawSize>::enqueue(T element)
template <typename T, unsigned rawSize> bool FIFO<T, rawSize>::enqueue(T element)
{
if(full()) {
return false;
Expand All @@ -85,7 +85,7 @@ template <typename T, int rawSize> bool FIFO<T, rawSize>::enqueue(T element)
return true;
}

template <typename T, int rawSize> T FIFO<T, rawSize>::dequeue()
template <typename T, unsigned rawSize> T FIFO<T, rawSize>::dequeue()
{
T item;
numberOfElements--;
Expand All @@ -95,12 +95,12 @@ template <typename T, int rawSize> T FIFO<T, rawSize>::dequeue()
return item;
}

template <typename T, int rawSize> T FIFO<T, rawSize>::peek() const
template <typename T, unsigned rawSize> T FIFO<T, rawSize>::peek() const
{
return raw[nextOut];
}

template <typename T, int rawSize> void FIFO<T, rawSize>::flush()
template <typename T, unsigned rawSize> void FIFO<T, rawSize>::flush()
{
nextIn = nextOut = numberOfElements = 0;
}
Expand Down
20 changes: 10 additions & 10 deletions Sming/Wiring/FILO.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

#include "Countable.h"

template <typename T, int rawSize> class FILO : public Countable<T>
template <typename T, unsigned rawSize> class FILO : public Countable<T>
{
public:
const int size; // speculative feature, in case it's needed
const unsigned size; // speculative feature, in case it's needed

FILO();

Expand Down Expand Up @@ -59,18 +59,18 @@ template <typename T, int rawSize> class FILO : public Countable<T>
}

private:
volatile int numberOfElements;
int nextIn;
int nextOut;
unsigned numberOfElements;
unsigned nextIn;
unsigned nextOut;
T raw[rawSize];
};

template <typename T, int rawSize> FILO<T, rawSize>::FILO() : size(rawSize)
template <typename T, unsigned rawSize> FILO<T, rawSize>::FILO() : size(rawSize)
{
flush();
}

template <typename T, int rawSize> bool FILO<T, rawSize>::push(T element)
template <typename T, unsigned rawSize> bool FILO<T, rawSize>::push(T element)
{
if(count() >= rawSize) {
return false;
Expand All @@ -79,23 +79,23 @@ template <typename T, int rawSize> bool FILO<T, rawSize>::push(T element)
return true;
}

template <typename T, int rawSize> T FILO<T, rawSize>::pop()
template <typename T, unsigned rawSize> T FILO<T, rawSize>::pop()
{
if(numberOfElements > 0) {
return raw[--numberOfElements];
}
return raw[0];
}

template <typename T, int rawSize> T FILO<T, rawSize>::peek() const
template <typename T, unsigned rawSize> T FILO<T, rawSize>::peek() const
{
if(numberOfElements > 0) {
return raw[numberOfElements - 1];
}
return raw[0];
}

template <typename T, int rawSize> void FILO<T, rawSize>::flush()
template <typename T, unsigned rawSize> void FILO<T, rawSize>::flush()
{
nextIn = nextOut = numberOfElements = 0;
}

0 comments on commit 950fc35

Please sign in to comment.