getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] (no subject)


From: Andriy Andreykiv
Subject: [Getfem-commits] (no subject)
Date: Fri, 9 Nov 2018 09:13:29 -0500 (EST)

branch: comparing_global_objects_by_key
commit e9270a80d4916fa5b04b3e1606b0f6d5776f460c
Author: Andriy.Andreykiv <address@hidden>
Date:   Fri Nov 9 15:11:43 2018 +0100

    further refining comparison for convex_structure pointers
---
 src/bgeot_convex_structure.cc       | 26 ++++++++++++++++++++++++++
 src/getfem/bgeot_convex_structure.h | 17 ++++++++---------
 2 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/src/bgeot_convex_structure.cc b/src/bgeot_convex_structure.cc
index fe927e9..f451ea2 100644
--- a/src/bgeot_convex_structure.cc
+++ b/src/bgeot_convex_structure.cc
@@ -108,6 +108,32 @@ namespace bgeot {
       : type(t), N(NN), K(KK), nf(nnf)  {}
   };
 
+  bool operator==(const pconvex_structure &p1, const pconvex_structure &p2){
+    if (!p1 || !p2) return p1.get() == p2.get();
+    if (p1.get() == p2.get()) return true;
+    else return *dal::key_of_stored_object(p1) == 
*dal::key_of_stored_object(p2);
+  }
+
+  bool operator!=(const pconvex_structure &p1, const pconvex_structure &p2){
+    return !(p1 == p2);
+  }
+
+  bool operator==(const pconvex_structure &p1, std::nullptr_t){
+    return p1.get() == nullptr;
+  }
+
+  bool operator==(std::nullptr_t, const pconvex_structure &p2){
+    return p2 == nullptr;
+  }
+
+  bool operator!=(const pconvex_structure &p1, std::nullptr_t){
+    return !(p1 == nullptr);
+  }
+
+  bool operator!=(std::nullptr_t, const pconvex_structure &p2){
+    return !(p2 == nullptr);
+  }
+
   /* ******************************************************************** */
   /* simplex structures                                                   */
   /* ******************************************************************** */
diff --git a/src/getfem/bgeot_convex_structure.h 
b/src/getfem/bgeot_convex_structure.h
index 5b4f659..9664ef7 100644
--- a/src/getfem/bgeot_convex_structure.h
+++ b/src/getfem/bgeot_convex_structure.h
@@ -159,15 +159,14 @@ namespace bgeot {
   *   they are duplicated in storages of multiple threads and pointers to them 
are
   *   never equal
   */
-  inline bool operator==(const pconvex_structure &p1, const pconvex_structure 
&p2)
-  {
-    return *dal::key_of_stored_object(p1) == *dal::key_of_stored_object(p2);
-  }
-
-  inline bool operator!=(const pconvex_structure &p1, const pconvex_structure 
&p2)
-  {
-    return !(p1 == p2);
-  }
+  bool operator==(const pconvex_structure &p1, const pconvex_structure &p2);
+  bool operator!=(const pconvex_structure &p1, const pconvex_structure &p2);
+
+  //!these operators still use comparison by addresses against nullptr
+  bool operator==(const pconvex_structure &p1, std::nullptr_t);
+  bool operator==(std::nullptr_t, const pconvex_structure &p2);
+  bool operator!=(const pconvex_structure &p1, std::nullptr_t);
+  bool operator!=(std::nullptr_t, const pconvex_structure &p2);
 
   /// Original structure (if concerned)
   inline pconvex_structure basic_structure(pconvex_structure cv)



reply via email to

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