Skip to content

Commit

Permalink
return default if vectors are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
kh9sd committed Oct 15, 2023
1 parent 610a685 commit b3ff8cd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/utils/SensorDataUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ SensorData medianData(std::vector<SensorData> datas) {
"Function not updated from CommandData change, please update this function and the static_assert");
static_assert(SensorData::majorVersion == 4,
"Function not updated from SensorData change, please update this function and the static_assert");
if (datas.empty()){
return SensorData{};
}

SensorData result;

result.loxVent = datas.back().loxVent;
Expand Down Expand Up @@ -98,6 +102,10 @@ SensorData averageData(std::vector<SensorData> datas) {
"Function not updated from CommandData change, please update this function and the static_assert");
static_assert(SensorData::majorVersion == 4,
"Function not updated from SensorData change, please update this function and the static_assert");
if (datas.empty()){
return SensorData{};
}

SensorData result;

result.loxVent = datas.back().loxVent;
Expand Down

0 comments on commit b3ff8cd

Please sign in to comment.