diff options
author | Victor Zverovich <viz@meta.com> | 2023-12-30 07:43:21 -0800 |
---|---|---|
committer | Victor Zverovich <viz@meta.com> | 2023-12-30 07:43:21 -0800 |
commit | 5ddd0cad15999439bbf96aa2e5241e9dced848ed (patch) | |
tree | b2c335ab18fbfa56be444ffebeae3f9989e7a41a | |
parent | 41d31512b7c6cb849b6540b68f01746c451cbdd1 (diff) | |
download | fmtlib-5ddd0cad15999439bbf96aa2e5241e9dced848ed.tar.gz |
Add a visitor for scan arguments
-rw-r--r-- | test/scan.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/scan.h b/test/scan.h index e368f37b..6217f223 100644 --- a/test/scan.h +++ b/test/scan.h @@ -363,6 +363,30 @@ class scan_arg { custom.scan = scan_custom_arg<T>; } + template <typename Visitor> + auto visit(Visitor&& vis) -> decltype(vis(std::declval<int>())) { + switch (type) { + case scan_type::none_type: + break; + case scan_type::int_type: + return vis(int_value); + case scan_type::uint_type: + return vis(uint_value); + case scan_type::long_long_type: + return vis(long_long_value); + case scan_type::ulong_long_type: + return vis(ulong_long_value); + case scan_type::string_type: + return vis(string); + case scan_type::string_view_type: + return vis(string_view); + case scan_type::custom_type: + // TODO: implement + break; + } + return vis(monostate()); + } + private: template <typename T> static void scan_custom_arg(void* arg, scan_parse_context& parse_ctx, |