freepooma-devel
[Top][All Lists]
Advanced

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

[PATCH] Fix dynamic_array_test5


From: Richard Guenther
Subject: [PATCH] Fix dynamic_array_test5
Date: Thu, 30 Jan 2003 12:18:49 +0100 (CET)

Hi!

The following patch fixes dynamic_array_test5 on targets that dont
support auto-converting std::vector<int>::iterator to int* by introducing
an extra constructor to IteratorPairDomain that does this conversion
explicitly.

Ok?

Richard.


diff -Nru a/r2/src/Domain/IteratorPairDomain.h 
b/r2/src/Domain/IteratorPairDomain.h
--- a/r2/src/Domain/IteratorPairDomain.h        Thu Jan 30 12:16:28 2003
+++ b/r2/src/Domain/IteratorPairDomain.h        Thu Jan 30 12:16:28 2003
@@ -199,6 +199,17 @@
     size_m = std::distance(begin_m,end_m);
   }

+  // Secondary constructor taking two "compatible" iterators.
+  // Works around the problem with std::vector<int>::iterator not
+  // convertible to int*. Ideally we would enable this specialized
+  // for Iter == int*/const int* only.
+  template <class Iter2>
+  IteratorPairDomain(Iter2 begin, Iter2 end)
+    : begin_m(&*begin), end_m(&*end)
+  {
+    size_m = std::distance(begin_m,end_m);
+  }
+
   // Copy constructors

   IteratorPairDomain(const This_t &a)
diff -Nru a/r2/src/DynamicArray/tests/dynamic_array_test5.cpp 
b/r2/src/DynamicArray/tests/dynamic_array_test5.cpp
--- a/r2/src/DynamicArray/tests/dynamic_array_test5.cpp Thu Jan 30 12:16:28 2003
+++ b/r2/src/DynamicArray/tests/dynamic_array_test5.cpp Thu Jan 30 12:16:28 2003
@@ -214,29 +214,7 @@

   // No destroy method specified --- should use BackFill() by default.

-  // NOTE: This may not compile!!! It depends on vector<int>::iterator
-  // being assignable to "const int *", which is not guaranteed.  The
-  // problem is that the patch-based destroy operation results in a
-  // virtual function call to all observers of the underlying layout,
-  // with the type of the event passed via an event base class. The
-  // handler code must then determine the event type, which is
-  // different for every possible domain type. The problem is that
-  // vector<int>::const_iterator is usually a typedef for "const int
-  // *" (and vector<int>::iterator is a typedef for "int *"), and thus
-  // this code will work (and furthermore it is impossible to
-  // enumerate them as different types, since they're not). But on
-  // some systems this isn't the case. It would be nice to support
-  // vector<int>::iterator even when it is a separate type, but I
-  // don't know how to do this within the language. If someone else
-  // wants to conditionally compile a seperate execution path for
-  // this, and add the necessary configuration options, that would
-  // probably be the best solution. For now, I've put #if 1...#endif
-  // around the call and if it fails to compile, just change it to
-  // #if 0. [JAC]
-
-#if 1
   b2.destroy(kfoo.begin(),kfoo.end(),6);
-#endif

   a2.sync();


reply via email to

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