Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 19, 2024
1 parent 50b02f0 commit ad70c66
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions transformer_engine/common/util/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@ inline const std::string &to_string_like(const std::string &val) noexcept { retu
constexpr const char *to_string_like(const char *val) noexcept { return val; }

/* \brief Convert arithmetic type to string */
template <typename T,
typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
inline std::string to_string_like(const T &val) {
return std::to_string(val);
}

/* \brief Convert container to string */
template <typename T,
typename = typename std::enable_if<!std::is_arithmetic<T>::value>::type,
template <typename T, typename = typename std::enable_if<!std::is_arithmetic<T>::value>::type,
typename = decltype(std::declval<T>().begin())>
inline std::string to_string_like(const T &container) {
std::string str;
str.reserve(1024); // Assume strings are <1 KB
str += "(";
bool first = true;
for (const auto &val: container) {
for (const auto &val : container) {
if (!first) {
str += ",";
}
Expand Down

0 comments on commit ad70c66

Please sign in to comment.