<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ydb/library/cpp/yt/string/format_string.h, branch CLI_2.22.0</title>
<subtitle>Mirror of YDB github repos</subtitle>
<id>https://code.mastervirt.ru/ydb/atom?h=CLI_2.22.0</id>
<link rel='self' href='https://code.mastervirt.ru/ydb/atom?h=CLI_2.22.0'/>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/'/>
<updated>2024-11-18T12:04:54Z</updated>
<entry>
<title>YT-23435: Parse format string at compile time</title>
<updated>2024-11-18T12:04:54Z</updated>
<author>
<name>arkady-e1ppa</name>
<email>arkady-e1ppa@yandex-team.com</email>
</author>
<published>2024-11-18T11:48:05Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=9e876c7c66440327e3bba353d37e99d68eabb0b9'/>
<id>urn:sha1:9e876c7c66440327e3bba353d37e99d68eabb0b9</id>
<content type='text'>
commit_hash:804530d1ee861ff42d7d8cad25d9f569b4feaacf
</content>
</entry>
<entry>
<title>YT-22512: Static analysis for TError method, ctors and related macros</title>
<updated>2024-08-13T19:42:11Z</updated>
<author>
<name>arkady-e1ppa</name>
<email>arkady-e1ppa@yandex-team.com</email>
</author>
<published>2024-08-13T19:30:08Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=a22375f74c2d4696846adf89626ca853b08cc782'/>
<id>urn:sha1:a22375f74c2d4696846adf89626ca853b08cc782</id>
<content type='text'>
Static analysis enabled for TError creation and related macros

TRuntimeFormat can be used to disable this feature, but requires copying the viewed object.
See NYT::TError::DisableFormat overloads to optimize constructions which want to move the given string

Note to future readers: TError is not "perfect-forwarding" unfriendly class. This means that the code
```
template &lt;class... TArgs&gt;
TError MakeError(TArgs&amp;&amp;... args) {
  return TError(std::forward&lt;TArgs&gt;(args)...);
}
```
will not compile and needs to be properly adjusted (see. TError::Wrap for implementation example)

This implies that emplace construction in containers will not work either. Use move construction instead, as it is simply a pointer swap and therefore free

Annotations: [nodiff:caesar]
cff12f05849402d09a4487bad26ffcd968215dc7
</content>
</entry>
<entry>
<title>YT-22473: Enable for-each formatting in known ranges</title>
<updated>2024-08-07T11:35:26Z</updated>
<author>
<name>arkady-e1ppa</name>
<email>arkady-e1ppa@yandex-team.com</email>
</author>
<published>2024-08-07T10:31:32Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=b92a4e77b0ee24fc7ae9d4488d97999ac39f48e3'/>
<id>urn:sha1:b92a4e77b0ee24fc7ae9d4488d97999ac39f48e3</id>
<content type='text'>
5a3405e64b730f0056e381af07658d6c2edcb92b
</content>
</entry>
<entry>
<title>YT-21868: Enable stat analysis in some other places</title>
<updated>2024-06-13T14:13:41Z</updated>
<author>
<name>arkady-e1ppa</name>
<email>arkady-e1ppa@yandex-team.com</email>
</author>
<published>2024-06-13T13:50:14Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=3a8a5fac5ba669fa5bed1ccd92e75bdfc6d30d21'/>
<id>urn:sha1:3a8a5fac5ba669fa5bed1ccd92e75bdfc6d30d21</id>
<content type='text'>
We slightly rework inner workings of stat analysis. For almost any sane use case the behavior is identical, but should compile a little faster.

If you send string literals like `char[N]` or `const char*` make them constexpr. If you can't (e.g. `ex.what()` case) wrap it in `TStringBuf`, if you want the "by the book; 100% right" solution then wrap it in `TRuntimeFormat` instead.

`SetRequestInfo` methods now statically checks the format. Only one error was found -- hooray!

Some other internal stuff was added, a lot removed -- don't worry about it. You won't be able to see the difference
62050dfe8a9cedc1289f18e80397ff33a8e2ecdb
</content>
</entry>
<entry>
<title>YT-21868: Refactor NYT::Format</title>
<updated>2024-06-07T10:27:39Z</updated>
<author>
<name>arkady-e1ppa</name>
<email>arkady-e1ppa@yandex-team.com</email>
</author>
<published>2024-06-07T10:13:50Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=327232940ecda2082cbcd9551049456522bbaffe'/>
<id>urn:sha1:327232940ecda2082cbcd9551049456522bbaffe</id>
<content type='text'>
NYT::Format had several problems:
1. There are too many ways to enable printing of T. Not all are equally good. You could specialize TValueFormatter, you could write an overload of FormatValue, you could write an overload of ToString, you could write an overload of operator &lt;&lt; for special stream or you could specialize the Out function.
2. If you attempt to print T which cannot be printed, you get a linker error without a proper source location which is very frustrating to work with.
3. There is no static analysis of format string performed even when it is possible.
4. If you write FormatValue overload, you still have to write ToString overload if you want to use this function (and people tend to use it quite a bit, since it is defined for util types and enums.

This pr addresses these issues to some extent. Relevant changes:
1. The only way to support NYT::Format is to define the FormatValue overload. Otherwise, you get a compile-time error.
2. Format overloads have changed: Now you have two options for general use:
```
TString Format(TStaticFormat&lt;TArgs...&gt; fmt, TArgs&amp;&amp;... args);
TString Format(TRuntimeFormat fmt, TArgs&amp;&amp;... args);
```
Either overload checks if TArg has a FormatValue overload. TStaticFormat performs a compile-time check of flags and the argument count. It binds to any string literal and constexpr string/string_view (and TStringBuf). TRuntimeFormat has to be mentioned explicitly. Otherwise, you will get a compile-time error for using runtime variable as a format.

3(!!!). Types which name begins with NYT:: have a specialization of ToString function which uses FormatValue. Thus, if you write class in namespace NYT and define FormatValue, you get ToString automatically. If your type is not from namespace enclosing NYT, you can just call NYT::ToString for the same effect. This limitation was caused by the fact, that we cannot review all of the external projects code which might inherit from stl  classes or adopt some other questionable code practises which may completely break the dispatching mechanism of ToString due to the specialization (there were such cases). Proper documentation of this library will be added soon, so that this interaction is made known. This limitation might be lifted later
77beb68082e10aaf48be1842aad8aba63f26c1bd
</content>
</entry>
</feed>
