freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pooma-dev] [PATCH] Another PrintField tweak


From: Jeffrey D. Oldham
Subject: Re: [pooma-dev] [PATCH] Another PrintField tweak
Date: Wed, 24 Mar 2004 02:13:16 -0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031107 Debian/1.5-3

Richard Guenther wrote:

Hi!

This allows more cases of expression printing, like

pinfo << 2.0*a;

or more complex expressions.

The problem was the
PerformPrintField<S,A,A::dimensions>::print(*this, s, a.subField(m, c));
call in the PrintField::print() method and the prototype for the
PerformPrinfField::print method without a suitable auto-conversion from
the result type of a.subField(m, c) back to A.

Fixed by effectively removing the Metrowerks workaround and templating
the member of PerformPrintField on A, S, rather than PerformPrintField
itself.  The workaround is from 12-Aug-99, so the compiler had rather been
fixed until now.

The PrintArray counterpart works (including the same workaround), because
we don't take subfield-views here and the types can match exactly.


Yes, thanks for improving printing.

2004Mar23  Richard Guenther <address@hidden>

        * src/Field/PrintField.h: template PerformPrintField on Dim
        only, template member on stream and field instead.

===== PrintField.h 1.4 vs edited =====
--- 1.4/r2/src/Field/PrintField.h       Thu Jan 29 12:01:39 2004
+++ edited/PrintField.h Tue Mar 23 09:58:02 2004
@@ -71,23 +71,24 @@

/**
 * PerformPrintField struct: a simple wrapper around the templated 'print'
- * method of PrintField.  This is here as a workaround to a Metrowerks
- * problem that prevents having templated member functions defined as
- * out-of-line.  This struct defines one static method 'print', which
+ * method of PrintField.
+ * This struct defines one static method 'print', which
 * prints an field to a stream (the two template parameters).  The Dim
 * parameter is used to specialize this to the case of a 1D domain.  This is
 * called by the 'print' templated member function of PrintField.
 */

-template<class S, class A, int Dim>
+template<int Dim>
struct PerformPrintField
{
+  template <class S, class A>
  static void print(const PrintField &, S &, const A &);
};

-template<class S, class A>
-struct PerformPrintField<S, A, 1>
+template<>
+struct PerformPrintField<1>
{
+  template<class S, class A>
  static void print(const PrintField &, S &, const A &);
};

@@ -239,7 +240,7 @@
          {
            s << "Material #" << m << ", Centering #" << c << " " << 
a.centering(c)
              << "\n"<< "-------------\n";
-            PerformPrintField<S,A,A::dimensions>::print(*this, s, 
a.subField(m, c));
+            PerformPrintField<A::dimensions>::print(*this, s, a.subField(m, 
c));
          }
    }

@@ -375,7 +376,7 @@

template<class S, class A>
void
-PerformPrintField<S,A,1>::print(const PrintField &p, S &s, const A &a)
+PerformPrintField<1>::print(const PrintField &p, S &s, const A &a)
{
  // make sure this is the right function

@@ -459,9 +460,10 @@
*/
//-----------------------------------------------------------------------------

-template<class S, class A, int Dim>
+template<int Dim>
+template<class S, class A>
void
-PerformPrintField<S,A,Dim>::print(const PrintField &p, S &s, const A &a)
+PerformPrintField<Dim>::print(const PrintField &p, S &s, const A &a)
{
  int i, j, k;



--
Jeffrey D. Oldham
address@hidden


reply via email to

[Prev in Thread] Current Thread [Next in Thread]