From a7fefb0ebf7c6207f5b6bd184534ef86bcbcf394 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Sat, 20 May 2017 12:10:15 -0400 Subject: [PATCH] common: Forward-declare container I/O overloads This will allow strict ADL to find the right overload in the case of a container of containers and unbreak compilation with Clang. Signed-off-by: Adam C. Emerson --- src/include/types.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/include/types.h b/src/include/types.h index 788fa9b3ca1af..1f0ee2b03a35a 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -90,6 +90,29 @@ typedef off_t loff_t; // -- io helpers -- +// Forward declare all the I/O helpers so strict ADL can find them in +// the case of containers of containers. I'm tempted to abstract this +// stuff using template templates like I did for denc. + +template +inline ostream& operator<<(ostream&out, const pair& v); +template +inline ostream& operator<<(ostream& out, const vector& v); +template +inline ostream& operator<<(ostream& out, const deque& v); +template +inline ostream& operator<<(ostream&out, const boost::tuple &t); +template +inline ostream& operator<<(ostream& out, const list& ilist); +template +inline ostream& operator<<(ostream& out, const set& iset); +template +inline ostream& operator<<(ostream& out, const multiset& iset); +template +inline ostream& operator<<(ostream& out, const map& m); +template +inline ostream& operator<<(ostream& out, const multimap& m); + template inline ostream& operator<<(ostream& out, const pair& v) { return out << v.first << "," << v.second; -- 2.39.5