Skip to content

Commit

Permalink
fix failed in c++17
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Dec 12, 2023
1 parent 033a23e commit 4341f6b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/struct_pack/benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ void run_benchmark(const T& map, LibType base_line_type) {
calculate_ser_rate(map, base_line_type, SampleType::RECTS, SampleType::RECTS);
calculate_ser_rate(map, base_line_type, SampleType::VAR_RECTS,
SampleType::RECTS);
#if __cplusplus >= 202002L
calculate_ser_rate(map, base_line_type, SampleType::ZC_RECTS,
SampleType::RECTS);
#endif
calculate_ser_rate(map, base_line_type, SampleType::PERSON,
SampleType::PERSON);
calculate_ser_rate(map, base_line_type, SampleType::PERSONS,
Expand All @@ -100,8 +104,10 @@ void run_benchmark(const T& map, LibType base_line_type) {
SampleType::MONSTER);
calculate_ser_rate(map, base_line_type, SampleType::MONSTERS,
SampleType::MONSTERS);
#if __cplusplus >= 202002L
calculate_ser_rate(map, base_line_type, SampleType::ZC_MONSTERS,
SampleType::MONSTERS);
#endif
}

int main(int argc, char** argv) {
Expand Down
3 changes: 2 additions & 1 deletion src/struct_pack/benchmark/data_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct Monster {
equipped, path);
#endif
};

#if __cplusplus >= 202002L
struct zc_Weapon {
std::string_view name;
int16_t damage;
Expand Down Expand Up @@ -175,3 +175,4 @@ struct zc_Monster {
equipped == rhs.equipped;
};
};
#endif
4 changes: 4 additions & 0 deletions src/struct_pack/benchmark/struct_pack_sample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,20 @@ struct struct_pack_sample : public base_sample {
deserialize(SampleType::RECTS, rects_);
deserialize(SampleType::VAR_RECT, rect2s_[0]);
deserialize(SampleType::VAR_RECTS, rect2s_);
#if __cplusplus >= 202002L
auto sp = std::span{rects_};
deserialize(SampleType::ZC_RECTS, sp);
#endif
deserialize(SampleType::PERSON, persons_[0]);
deserialize(SampleType::PERSONS, persons_);
deserialize<std::vector<person>, std::vector<zc_person>>(
SampleType::ZC_PERSONS, persons_);
deserialize(SampleType::MONSTER, monsters_[0]);
deserialize(SampleType::MONSTERS, monsters_);
#if __cplusplus >= 202002L
deserialize<std::vector<Monster>, std::vector<zc_Monster>>(
SampleType::ZC_MONSTERS, monsters_);
#endif
}

private:
Expand Down

0 comments on commit 4341f6b

Please sign in to comment.