From 4341f6b64ac5c71d0af199d83b9f59be55060f56 Mon Sep 17 00:00:00 2001 From: "Zezheng.Li" Date: Tue, 12 Dec 2023 15:51:35 +0800 Subject: [PATCH] fix failed in c++17 --- src/struct_pack/benchmark/benchmark.cpp | 6 ++++++ src/struct_pack/benchmark/data_def.hpp | 3 ++- src/struct_pack/benchmark/struct_pack_sample.hpp | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/struct_pack/benchmark/benchmark.cpp b/src/struct_pack/benchmark/benchmark.cpp index d7c86ce4c..b38565014 100644 --- a/src/struct_pack/benchmark/benchmark.cpp +++ b/src/struct_pack/benchmark/benchmark.cpp @@ -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, @@ -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) { diff --git a/src/struct_pack/benchmark/data_def.hpp b/src/struct_pack/benchmark/data_def.hpp index 3593f988f..7c820d46a 100644 --- a/src/struct_pack/benchmark/data_def.hpp +++ b/src/struct_pack/benchmark/data_def.hpp @@ -144,7 +144,7 @@ struct Monster { equipped, path); #endif }; - +#if __cplusplus >= 202002L struct zc_Weapon { std::string_view name; int16_t damage; @@ -175,3 +175,4 @@ struct zc_Monster { equipped == rhs.equipped; }; }; +#endif \ No newline at end of file diff --git a/src/struct_pack/benchmark/struct_pack_sample.hpp b/src/struct_pack/benchmark/struct_pack_sample.hpp index c211169ff..a34bdb2c4 100644 --- a/src/struct_pack/benchmark/struct_pack_sample.hpp +++ b/src/struct_pack/benchmark/struct_pack_sample.hpp @@ -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>( SampleType::ZC_PERSONS, persons_); deserialize(SampleType::MONSTER, monsters_[0]); deserialize(SampleType::MONSTERS, monsters_); +#if __cplusplus >= 202002L deserialize, std::vector>( SampleType::ZC_MONSTERS, monsters_); +#endif } private: