mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
Add stringify() to util/str
This commit is contained in:
parent
ca67c12928
commit
858e252820
|
@ -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…
Reference in a new issue