Add stringify() to util/str

pull/1186/head
Stephen Shelton 4 years ago
parent ca67c12928
commit 858e252820
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C

@ -2,6 +2,7 @@
#define LLARP_STR_HPP
#include <util/string_view.hpp>
#include <sstream>
namespace llarp
{
@ -28,6 +29,18 @@ namespace llarp
string_view
TrimWhitespace(string_view str);
template<typename... T>
std::string stringify(T&&... stuff)
{
std::ostringstream o;
#ifdef __cpp_fold_expressions
(o << ... << std::forward<T>(stuff));
#else
(void) std::initializer_list<int>{(o << std::forward<T>(stuff), 0)...};
#endif
return o.str();
}
} // namespace llarp
#endif

Loading…
Cancel
Save