From c4b1faf6aeb44a30c6eb7008dbb36afa8e21530b Mon Sep 17 00:00:00 2001 From: maier Date: Wed, 16 Oct 2013 13:53:08 +0000 Subject: [PATCH] Bugfix: Declare LogStream::operator<< as a non member function to get compatible results under C++11 overload resolution rules git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@31255 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/logstream.h | 37 ++++++++++++------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/deal.II/include/deal.II/base/logstream.h b/deal.II/include/deal.II/base/logstream.h index 8afb3ea2cb..fe03109f66 100644 --- a/deal.II/include/deal.II/base/logstream.h +++ b/deal.II/include/deal.II/base/logstream.h @@ -361,13 +361,6 @@ public: std::ios::fmtflags flags(const std::ios::fmtflags f); - /** - * Output a constant something through this stream. - */ - template - LogStream &operator << (const T &t); - - /** * Output double precision numbers through this stream. * @@ -557,12 +550,31 @@ private: * for every thread that sends log messages. */ Threads::ThreadLocalStorage > outstreams; + + template friend LogStream &operator << (LogStream & log, const T &t); }; /* ----------------------------- Inline functions and templates ---------------- */ +/** + * Output a constant something through LogStream: + * + * @note We declare this operator as a non-member function so that it is + * possible to overload it with more specialized templated versions under + * C++11 overload resolution rules + */ +template +inline +LogStream & operator<< (LogStream &log, const T &t) +{ + // print to the internal stringstream + log.get_stream() << t; + return log; +} + + inline std::ostringstream & LogStream::get_stream() @@ -586,17 +598,6 @@ LogStream::get_stream() } -template -inline -LogStream & -LogStream::operator<< (const T &t) -{ - // print to the internal stringstream - get_stream() << t; - - return *this; -} - inline -- 2.39.5