diff --git a/include/spii/string_utils.h b/include/spii/string_utils.h index 5451740..5229742 100644 --- a/include/spii/string_utils.h +++ b/include/spii/string_utils.h @@ -32,38 +32,8 @@ namespace spii // and combinations thereof, e.g. vector>. namespace { - void add_to_stream(std::ostream*) - { } - - template - void add_to_stream(std::ostream* stream, T&& t, Args&&... args) - { - (*stream) << std::forward(t); - add_to_stream(stream, std::forward(args)...); - } - - std::string to_string() - { - return{}; - } - - // Overload for string literals. - template - std::string to_string(const char(&c_str)[n]) - { - return{c_str}; - } - - template - std::string to_string(Args&&... args) - { - std::ostringstream stream; - add_to_stream(&stream, std::forward(args)...); - return stream.str(); - } - template - std::ostream& operator<<(std::ostream& stream, std::pair p) + std::ostream& operator<<(std::ostream& stream, const std::pair& p) { stream << '(' << p.first << ", " << p.second << ')'; return stream; @@ -140,6 +110,36 @@ namespace { stream << ']'; return stream; } + + void add_to_stream(std::ostream*) + { } + + template + void add_to_stream(std::ostream* stream, T&& t, Args&&... args) + { + (*stream) << std::forward(t); + add_to_stream(stream, std::forward(args)...); + } + + std::string to_string() + { + return{}; + } + + // Overload for string literals. + template + std::string to_string(const char(&c_str)[n]) + { + return{c_str}; + } + + template + std::string to_string(Args&&... args) + { + std::ostringstream stream; + add_to_stream(&stream, std::forward(args)...); + return stream.str(); + } } template