]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Work around a problem in Suns Forte compiler, which choked on the explicit qualificat...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 20 Mar 2002 12:43:38 +0000 (12:43 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 20 Mar 2002 12:43:38 +0000 (12:43 +0000)
/* --------------------------------------- */
/* Problem 9 -- selecting member templates */
/* by template keyword                   */
/* (Why does it make a difference whether  */
/* member function or operator?)           */
class T7 {
    template <typename T> void operator << (T);
    template <typename T> void f (T);
    void g() {
      this->template f<int> (1);           // OK!
      this->template operator<< <int> (1); // not!
    };
};

Work around by introducing a common function for the template and the nontemplate function.

git-svn-id: https://svn.dealii.org/trunk@5598 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/logstream.h

index 64b46456482e702d567d56d15af426bf4f22fa48..ee1b9c7c14cbf031a03cff8e3458c71602134720 100644 (file)
@@ -158,8 +158,8 @@ class LogStream
     void log_time_differences (bool flag);
     
                                     /**
-                                     * Output a constant something through
-                                     * this stream.
+                                     * Output a constant something
+                                     * through this stream.
                                      */
     template <typename T>
     LogStream & operator << (const T &t);
@@ -281,6 +281,16 @@ class LogStream
                                      * the contents of the prefix stack.
                                      */
     void print_line_head();
+
+                                    /**
+                                     * Actually do the work of
+                                     * writing output. This function
+                                     * unifies the work that is
+                                     * common to the two
+                                     * @p{operator<<} functions.
+                                     */
+    template <typename T>
+    void print (const T &t);
 };
 
 
@@ -292,24 +302,11 @@ inline
 LogStream &
 LogStream::operator<< (const T& t)
 {
-                                  // if the previous command was an
-                                  // @p{std::endl}, print the topmost prefix
-                                  // and a colon
-  if (was_endl)
-    {
-      print_line_head();
-      was_endl = false;
-    };
-
-                                  // print the rest of the message
-  if (prefixes.size() <= std_depth)
-    *std_out << t;
-
-  if (file && (prefixes.size() <= file_depth))
-    *file << t;
-
+                                  // do the work that is common to
+                                  // the two operator<< functions
+  print (t);
   return *this;
-}
+};
 
 
 
@@ -317,9 +314,9 @@ inline
 LogStream &
 LogStream::operator<< (std::ostream& (*p) (std::ostream&))
 {
-                                  // first pass on to the other
-                                  // (templatized function)
-  this->template operator<< <std::ostream & (*)(std::ostream&)> (p);
+                                  // do the work that is common to
+                                  // the two operator<< functions
+  print (p);
 
                                   // next check whether this is the
                                   // @p{endl} manipulator, and if so
@@ -333,6 +330,30 @@ LogStream::operator<< (std::ostream& (*p) (std::ostream&))
 
 
 
+template <class T>
+inline
+void
+LogStream::print (const T &t)
+{
+                                  // if the previous command was an
+                                  // @p{std::endl}, print the topmost
+                                  // prefix and a colon
+  if (was_endl)
+    {
+      print_line_head();
+      was_endl = false;
+    };
+
+                                  // print the rest of the message
+  if (prefixes.size() <= std_depth)
+    *std_out << t;
+
+  if (file && (prefixes.size() <= file_depth))
+    *file << t;
+}
+
+
+
 /**
  * The standard log object of DEAL.
  *

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.