help-octave
[Top][All Lists]
Advanced

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

Re: compiling with Sun Studio


From: John W. Eaton
Subject: Re: compiling with Sun Studio
Date: Wed, 29 Aug 2007 13:28:35 -0400

On 29-Aug-2007, Jim Langston wrote:

| Don't know exactly what I need to do, I have looked at re-writing
| the class, but before I do, I wanted to make sure no one has attempted
| to get octave compiled with the Sun Studio compilers.
| 
| stlport4 tells the Sun compiler to use STLport's implementation of the
| standard library, which seems to be ok with the cast as written.
| 
| I have tried this:
| 
| class pid_equal
| {
| public:
| 
|   pid_equal (pid_t v) : val (v) { }
| 
|   bool operator () (const octave_child& oc) const { return oc.pid == val; }
|   bool operator () (const pid_equal& pid) const { return pid == val ; }
| 
| private:
| 
|   pid_t val;
| };
| 
| but this generates:
| 
| "sighandlers.cc", line 892: Error: Overloading ambiguity between 
| "operator==(const octave_int<long long>&, const octave_int<unsigned>&)" 
| and "operator==(const octave_int<unsigned>&, const octave_int<char>&)".

I don't think a simple modification to the pid_equal class is going to
fix the problem you are seeing.

Earlier, you wrote

  It is in sighandlers.cc, and I get this error:

  "./base-list.h", line 45: Error: Cannot cast from pid_equal to 
  bool(*)(const octave_child&).

so it seems that the remove_if function in the default library is
expecting a function pointer rather than a predicate class.  I don't
think that's the standard definition of remove_if.

How about the following patch?

jwe


src/ChangeLog:

2007-08-29  John W. Eaton  <address@hidden>

        * base-list.h (octave_base_list::remove): Implement our own
        remove_if function here.

Index: src/base-list.h
===================================================================
RCS file: /cvs/octave/src/base-list.h,v
retrieving revision 1.3
diff -u -u -r1.3 base-list.h
--- src/base-list.h     26 Apr 2005 19:24:32 -0000      1.3
+++ src/base-list.h     29 Aug 2007 17:25:54 -0000
@@ -42,7 +42,27 @@
   iterator erase (iterator pos) { return lst.erase (pos); }
 
   template <class P>
-  void remove_if (P pred) { lst.remove_if (pred); }
+  void remove_if (P pred)
+  {
+    // We would like to simply call
+    //
+    //   lst.remove_if (pred);
+    //
+    // but the Sun Studio compiler chokes on that.
+    //
+    // FIXME -- this kluge should be removed at some point.
+
+    iterator b = lst.begin ();
+    iterator e = lst.end ();
+    while (b != e)
+      {
+       iterator n = b;
+       n++;
+       if (pred (*b))
+         erase (b);
+       b = n;
+      }
+  }
 
   void clear (void) { lst.clear (); }
 

reply via email to

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