diff options
author | yurial <yurial@yandex-team.com> | 2023-11-15 19:04:49 +0300 |
---|---|---|
committer | yurial <yurial@yandex-team.com> | 2023-11-15 20:41:53 +0300 |
commit | 74b9f490cb9b078ae8675a7aa0947657371e294b (patch) | |
tree | b758a0d34c536195f36921b7a8e3cc85111cd3d6 /util/ysaveload.h | |
parent | c3af3ff02e15d03164a4b79b042490e41ce7c473 (diff) | |
download | ydb-74b9f490cb9b078ae8675a7aa0947657371e294b.tar.gz |
Allow to handle Y_SAVELOAD_DEFINE() without args
Diffstat (limited to 'util/ysaveload.h')
-rw-r--r-- | util/ysaveload.h | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/util/ysaveload.h b/util/ysaveload.h index 8771f1e4a1..52fd5bd8ef 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -726,24 +726,32 @@ static inline void LoadMany(S* s, Ts&... t) { ApplyToMany([&](auto& v) { Load(s, v); }, t...); } -#define Y_SAVELOAD_DEFINE(...) \ - inline void Save(IOutputStream* s) const { \ - ::SaveMany(s, __VA_ARGS__); \ - } \ - \ - inline void Load(IInputStream* s) { \ - ::LoadMany(s, __VA_ARGS__); \ - } \ +#define Y_SAVELOAD_DEFINE(...) \ + inline void Save(IOutputStream* s) const { \ + [s](auto&&... args) { \ + ::SaveMany(s, std::forward<decltype(args)>(args)...); \ + }(__VA_ARGS__); \ + } \ + \ + inline void Load(IInputStream* s) { \ + [s](auto&&... args) { \ + ::LoadMany(s, std::forward<decltype(args)>(args)...); \ + }(__VA_ARGS__); \ + } \ Y_SEMICOLON_GUARD -#define Y_SAVELOAD_DEFINE_OVERRIDE(...) \ - void Save(IOutputStream* s) const override { \ - ::SaveMany(s, __VA_ARGS__); \ - } \ - \ - void Load(IInputStream* s) override { \ - ::LoadMany(s, __VA_ARGS__); \ - } \ +#define Y_SAVELOAD_DEFINE_OVERRIDE(...) \ + void Save(IOutputStream* s) const override { \ + [s](auto&&... args) { \ + ::SaveMany(s, std::forward<decltype(args)>(args)...); \ + }(__VA_ARGS__); \ + } \ + \ + void Load(IInputStream* s) override { \ + [s](auto&&... args) { \ + ::LoadMany(s, std::forward<decltype(args)>(args)...); \ + }(__VA_ARGS__); \ + } \ Y_SEMICOLON_GUARD template <class T> |