Skip to content

Commit 680f5bf

Browse files
committed
fix string_format function to handle zero-argument case and fix compiler warning (format-security)
1 parent 12d9498 commit 680f5bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

include/Utils.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ inline std::vector<T> get_triangle_strip_outline_indices(const std::size_t num_v
276276
return out_indices;
277277
}
278278

279-
template<class... Args>
279+
inline std::string string_format(const char* fmt)
280+
{
281+
return fmt ? std::string(fmt) : std::string();
282+
}
283+
284+
template<class... Args, typename std::enable_if<(sizeof...(Args) > 0), int>::type = 0>
280285
std::string string_format(const char* fmt, Args&&... args)
281286
{
282287
const int n = std::snprintf(nullptr, 0, fmt, std::forward<Args>(args)...);

0 commit comments

Comments
 (0)