summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/string
diff options
context:
space:
mode:
authorarkady-e1ppa <[email protected]>2024-06-11 22:01:04 +0300
committerarkady-e1ppa <[email protected]>2024-06-12 11:47:00 +0300
commit89f56e044a4f82c7e88fa15771beca2d5787c7c8 (patch)
treeadb31c52e55de4c2131cf15ca722e64b609b1a10 /library/cpp/yt/string
parenta41bb65a80fdc183e427b6c337dbbc15776f1c92 (diff)
YT-21868: Delete unneeded ToString methods
e856aa45df227b86e8b121852d3774bb2504193b
Diffstat (limited to 'library/cpp/yt/string')
-rw-r--r--library/cpp/yt/string/format-inl.h16
-rw-r--r--library/cpp/yt/string/format_arg-inl.h7
-rw-r--r--library/cpp/yt/string/format_arg.h3
-rw-r--r--library/cpp/yt/string/string_builder-inl.h9
4 files changed, 21 insertions, 14 deletions
diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h
index acaa8f70115..8d0ef4de939 100644
--- a/library/cpp/yt/string/format-inl.h
+++ b/library/cpp/yt/string/format-inl.h
@@ -473,19 +473,19 @@ template <class T, class TPolicy>
void FormatValue(TStringBuilderBase* builder, const TMaybe<T, TPolicy>& value, TStringBuf spec);
// std::optional
-template <class T>
+template <CFormattable T>
void FormatValue(TStringBuilderBase* builder, const std::optional<T>& value, TStringBuf spec);
// std::pair
-template <class A, class B>
+template <CFormattable A, CFormattable B>
void FormatValue(TStringBuilderBase* builder, const std::pair<A, B>& value, TStringBuf spec);
// std::tuple
-template <class... Ts>
+template <CFormattable... Ts>
void FormatValue(TStringBuilderBase* builder, const std::tuple<Ts...>& value, TStringBuf spec);
// TEnumIndexedArray
-template <class E, class T>
+template <class E, CFormattable T>
void FormatValue(TStringBuilderBase* builder, const TEnumIndexedArray<E, T>& collection, TStringBuf spec);
// One-valued ranges
@@ -531,7 +531,7 @@ inline void FormatValue(TStringBuilderBase* builder, std::nullopt_t, TStringBuf
}
// std::optional: generic T
-template <class T>
+template <CFormattable T>
void FormatValue(TStringBuilderBase* builder, const std::optional<T>& value, TStringBuf spec)
{
if (value.has_value()) {
@@ -542,7 +542,7 @@ void FormatValue(TStringBuilderBase* builder, const std::optional<T>& value, TSt
}
// std::pair
-template <class A, class B>
+template <CFormattable A, CFormattable B>
void FormatValue(TStringBuilderBase* builder, const std::pair<A, B>& value, TStringBuf spec)
{
builder->AppendChar('{');
@@ -553,7 +553,7 @@ void FormatValue(TStringBuilderBase* builder, const std::pair<A, B>& value, TStr
}
// std::tuple
-template <class... Ts>
+template <CFormattable... Ts>
void FormatValue(TStringBuilderBase* builder, const std::tuple<Ts...>& value, TStringBuf spec)
{
builder->AppendChar('{');
@@ -571,7 +571,7 @@ void FormatValue(TStringBuilderBase* builder, const std::tuple<Ts...>& value, TS
}
// TEnumIndexedArray
-template <class E, class T>
+template <class E, CFormattable T>
void FormatValue(TStringBuilderBase* builder, const TEnumIndexedArray<E, T>& collection, TStringBuf spec)
{
builder->AppendChar('{');
diff --git a/library/cpp/yt/string/format_arg-inl.h b/library/cpp/yt/string/format_arg-inl.h
index 82a77a1249a..e2f08e540dc 100644
--- a/library/cpp/yt/string/format_arg-inl.h
+++ b/library/cpp/yt/string/format_arg-inl.h
@@ -27,6 +27,13 @@ constexpr bool IsNYTName()
return qualidName.find("NYT::") == 0;
}
+template <class T>
+constexpr bool IsStdName()
+{
+ constexpr auto qualidName = QualidName<T>();
+ return qualidName.find("std::") == 0;
+}
+
} // namespace NDetail
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/yt/string/format_arg.h b/library/cpp/yt/string/format_arg.h
index da7d13a19ba..6240059ed93 100644
--- a/library/cpp/yt/string/format_arg.h
+++ b/library/cpp/yt/string/format_arg.h
@@ -21,9 +21,6 @@ constexpr std::string_view QualidName();
template <class T>
constexpr bool IsNYTName();
-template <class T>
-concept CYtName = IsNYTName<T>();
-
} // namespace NDetail
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/yt/string/string_builder-inl.h b/library/cpp/yt/string/string_builder-inl.h
index 683a241c9cc..9fb3ae94f86 100644
--- a/library/cpp/yt/string/string_builder-inl.h
+++ b/library/cpp/yt/string/string_builder-inl.h
@@ -118,7 +118,7 @@ inline void TStringBuilder::DoReserve(size_t newLength)
////////////////////////////////////////////////////////////////////////////////
-inline void FormatValue(TStringBuilderBase* builder, const TStringBuilder& value, TStringBuf /*format*/)
+inline void FormatValue(TStringBuilderBase* builder, const TStringBuilder& value, TStringBuf /*spec*/)
{
builder->AppendString(value.GetBuffer());
}
@@ -165,14 +165,17 @@ TString ToStringIgnoringFormatValue(const T& t)
#include <util/string/cast.h>
-// util/string/cast.h extension for yt types only
+// util/string/cast.h extension for yt and std types only
// TODO(arkady-e1ppa): Abolish ::ToString in
// favour of either NYT::ToString or
// automatic formatting wherever it is needed.
namespace NPrivate {
template <class T>
- requires (NYT::NDetail::CYtName<T> && NYT::CFormattable<T>)
+ requires (
+ (NYT::NDetail::IsNYTName<T>() ||
+ NYT::NDetail::IsStdName<T>()) &&
+ NYT::CFormattable<T>)
struct TToString<T, false>
{
static TString Cvt(const T& t)