From: wolf Date: Wed, 20 Mar 2002 12:43:38 +0000 (+0000) Subject: Work around a problem in Suns Forte compiler, which choked on the explicit qualificat... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d71a72cc5baa99dac4660cef36edac33836d119;p=dealii-svn.git Work around a problem in Suns Forte compiler, which choked on the explicit qualification of a member template when that member template is an operator, as in /* --------------------------------------- */ /* Problem 9 -- selecting member templates */ /* by template keyword */ /* (Why does it make a difference whether */ /* member function or operator?) */ class T7 { template void operator << (T); template void f (T); void g() { this->template f (1); // OK! this->template operator<< (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 --- diff --git a/deal.II/base/include/base/logstream.h b/deal.II/base/include/base/logstream.h index 64b4645648..ee1b9c7c14 100644 --- a/deal.II/base/include/base/logstream.h +++ b/deal.II/base/include/base/logstream.h @@ -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 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 + 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<< (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 +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. *