File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -277,14 +277,13 @@ inline std::vector<T> get_triangle_strip_outline_indices(const std::size_t num_v
277277}
278278
279279template <class ... Args>
280- std::string string_format (std::string_view fmt, const Args&... args)
280+ std::string string_format (const char * fmt, Args& &... args)
281281{
282- const int n = std::snprintf (nullptr , 0 , fmt. data (), args...);
282+ const int n = std::snprintf (nullptr , 0 , fmt, std::forward<Args>( args) ...);
283283 if (n < 0 )
284284 throw std::runtime_error (" formatting failed" );
285- std::string out;
286- out.resize (static_cast <size_t >(n));
287- std::snprintf (out.data (), out.size () + 1 , fmt.data (), args...);
285+ std::string out (static_cast <size_t >(n), ' \0 ' ); // since c++11: str[str.size()] is '\0'
286+ std::snprintf (&out[0 ], out.size () + 1 , fmt, std::forward<Args>(args)...);
288287 return out;
289288}
290289
You can’t perform that action at this time.
0 commit comments