From 2095cb82a5d767af5912cffbdf4e8eebfe605ea2 Mon Sep 17 00:00:00 2001 From: Calle Wilund Date: Mon, 4 Dec 2017 13:11:52 +0000 Subject: [PATCH] utils::to_string: Add printers for pairs+maps --- to_string.hh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/to_string.hh b/to_string.hh index a1b9cb568e..50d65276d5 100644 --- a/to_string.hh +++ b/to_string.hh @@ -80,6 +80,12 @@ to_string(std::initializer_list items) { return "[" + join(", ", std::begin(items), std::end(items)) + "]"; } +template +std::ostream& operator<<(std::ostream& os, const std::pair& p) { + os << "{" << p.first << ", " << p.second << "}"; + return os; +} + template std::ostream& operator<<(std::ostream& os, const std::unordered_set& items) { os << "{" << join(", ", items) << "}"; @@ -98,6 +104,18 @@ std::ostream& operator<<(std::ostream& os, const std::array& items) { return os; } +template +std::ostream& operator<<(std::ostream& os, const std::unordered_map& items) { + os << "{" << join(", ", items) << "}"; + return os; +} + +template +std::ostream& operator<<(std::ostream& os, const std::map& items) { + os << "{" << join(", ", items) << "}"; + return os; +} + namespace experimental { template