From: Adam C. Emerson Date: Wed, 10 Jan 2018 04:28:37 +0000 (-0500) Subject: types: Output of arbitrary std::tuples X-Git-Tag: v13.0.2~525^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dcd6d70eef92f2574ff2908f76915c278796ce6f;p=ceph.git types: Output of arbitrary std::tuples Again, using ceph::for_each Signed-off-by: Adam C. Emerson --- diff --git a/src/include/types.h b/src/include/types.h index a5d533530e07..178051d323a2 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -101,8 +101,10 @@ 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 std::tuple &t); +template +inline ostream& operator<<(ostream& out, const boost::tuple &t); template inline ostream& operator<<(ostream& out, const list& ilist); template @@ -144,9 +146,21 @@ inline ostream& operator<<(ostream& out, const deque& v) { return out; } -template -inline ostream& operator<<(ostream&out, const boost::tuple &t) { - out << boost::get<0>(t) <<"," << boost::get<1>(t) << "," << boost::get<2>(t); +template +inline ostream& operator<<(ostream& out, const boost::tuple &t) { + return out << boost::get<0>(t) << "," + << boost::get<1>(t) << "," + << boost::get<2>(t); +} + +template +inline ostream& operator<<(ostream& out, const std::tuple &t) { + auto f = [n = sizeof...(Ts), i = 0, &out](const auto& e) mutable { + out << e; + if (++i != n) + out << ","; + }; + ceph::for_each(t, f); return out; }