]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Declare LogStream::operator<< as a non member function to get
authorMatthias Maier <tamiko@kyomu.43-1.org>
Wed, 16 Oct 2013 13:53:08 +0000 (13:53 +0000)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Wed, 16 Oct 2013 13:53:08 +0000 (13:53 +0000)
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

index 8afb3ea2cbc51c1de9971646c3f205afdda3588c..fe03109f66692760833061ae3716ef2a654e2806 100644 (file)
@@ -361,13 +361,6 @@ public:
   std::ios::fmtflags flags(const std::ios::fmtflags f);
 
 
-  /**
-   * Output a constant something through this stream.
-   */
-  template <typename T>
-  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<std_cxx1x::shared_ptr<std::ostringstream> > outstreams;
+
+  template <typename T> 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 <typename T>
+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 <class T>
-inline
-LogStream &
-LogStream::operator<< (const T &t)
-{
-  // print to the internal stringstream
-  get_stream() << t;
-
-  return *this;
-}
-
 
 
 inline

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.