diff options
author | ifsmirnov <ifsmirnov@yandex-team.com> | 2023-07-06 22:56:46 +0300 |
---|---|---|
committer | ifsmirnov <ifsmirnov@yandex-team.com> | 2023-07-06 22:56:46 +0300 |
commit | 3edecc646fd526f54d6cca6331130a9aafb52be4 (patch) | |
tree | 89dd719a90774a01e0bf5a123b71bc978c68c5a5 /library/cpp/yt/string/format-inl.h | |
parent | a106ebbbe062aa4b0c17a246be1acf8da6785556 (diff) | |
download | ydb-3edecc646fd526f54d6cca6331130a9aafb52be4.tar.gz |
Introduce TLazyMultiValueFormatter
Diffstat (limited to 'library/cpp/yt/string/format-inl.h')
-rw-r--r-- | library/cpp/yt/string/format-inl.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h index 2eb42cfb99..cb27961d3b 100644 --- a/library/cpp/yt/string/format-inl.h +++ b/library/cpp/yt/string/format-inl.h @@ -633,6 +633,35 @@ void FormatImpl( //////////////////////////////////////////////////////////////////////////////// +template <class... TArgs> +TLazyMultiValueFormatter<TArgs...>::TLazyMultiValueFormatter( + TStringBuf format, + TArgs&&... args) + : Format_(format) + , Args_(std::forward<TArgs>(args)...) +{ } + +template <class... TArgs> +void FormatValue( + TStringBuilderBase* builder, + const TLazyMultiValueFormatter<TArgs...>& value, + TStringBuf /*format*/) +{ + std::apply( + [&] <class... TInnerArgs> (TInnerArgs&&... args) { + builder->AppendFormat(value.Format_, std::forward<TInnerArgs>(args)...); + }, + value.Args_); +} + +template <class... TArgs> +auto MakeLazyMultiValueFormatter(TStringBuf format, TArgs&&... args) +{ + return TLazyMultiValueFormatter<TArgs...>(format, std::forward<TArgs>(args)...); +} + +//////////////////////////////////////////////////////////////////////////////// + template <class T> struct TFormatTraits { |