Skip to content

Commit b43d44b

Browse files
committed
refactor: global to_string -> ToString
1 parent f445c0c commit b43d44b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

include/snapshot/internal/string_utility.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313

1414
namespace snapshot {
1515

16+
namespace internal {
17+
18+
template <typename T, std::enable_if_t<internal::has_global_to_string_v<T>, bool> = true>
19+
inline std::string VisitGlobalToString(const T& t) {
20+
return ToString(t);
21+
}
22+
23+
} // namespace internal
24+
1625
class StringUtility {
1726
friend class StringUtilityTest;
1827

@@ -24,7 +33,7 @@ class StringUtility {
2433

2534
template <typename T, std::enable_if_t<internal::has_global_to_string_v<T>, bool> = true>
2635
static std::string ToString(const T& t) {
27-
return to_string(t);
36+
return internal::VisitGlobalToString(t);
2837
}
2938

3039
template <typename T, std::enable_if_t<internal::has_class_internal_to_string_v<T>, bool> = true>

include/snapshot/types_check/has_global_to_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ template <typename T>
99
class has_global_to_string {
1010
private:
1111
template <typename U>
12-
static auto check(int) -> decltype(to_string(std::declval<U>()), std::true_type());
12+
static auto check(int) -> decltype(ToString(std::declval<U>()), std::true_type());
1313

1414
template <typename U>
1515
static std::false_type check(...);

test/internal/string_utility_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CustomToString1 {
3131
int z;
3232
};
3333

34-
string to_string(const CustomToString1& c) {
34+
string ToString(const CustomToString1& c) {
3535
return to_string(c.x) + " " + to_string(c.y) + " " + to_string(c.z) + "\n";
3636
}
3737

0 commit comments

Comments
 (0)