From cf4977574a54b634090abfebd77a64b23ae949c4 Mon Sep 17 00:00:00 2001
From: Maximilian Reininghaus <maximilian.reininghaus@tu-dortmund.de>
Date: Tue, 6 Jun 2023 19:23:30 +0200
Subject: [PATCH] hotfix for ContinuousProcessIndex via pointer-to-process

---
 .../framework/process/ProcessSequence.inl      | 18 ++++++++++++------
 .../process/SwitchProcessSequence.inl          | 18 ++++++++++++------
 .../process/ContinuousProcessIndex.hpp         | 12 ++++++------
 3 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/corsika/detail/framework/process/ProcessSequence.inl b/corsika/detail/framework/process/ProcessSequence.inl
index 9a9cc4d4f..fc020079d 100644
--- a/corsika/detail/framework/process/ProcessSequence.inl
+++ b/corsika/detail/framework/process/ProcessSequence.inl
@@ -121,7 +121,9 @@ namespace corsika {
         //~ "doContinuous(TParticle [const]&,TTrack [const]&,bool)\" required for "
         //~ "ContinuousProcess<TDerived>. ");
 
-        ret |= A_.doContinuous(step, limitId == ContinuousProcessIndex(IndexProcess1));
+        ret |= A_.doContinuous(
+            step, limitId == ContinuousProcessIndex(
+                                 reinterpret_cast<void const*>(std::addressof(A_))));
       }
     }
 
@@ -142,7 +144,9 @@ namespace corsika {
         //~ "doContinuous(TParticle [const]&,TTrack [const]&,bool)\" required for "
         //~ "ContinuousProcess<TDerived>. ");
 
-        ret |= B_.doContinuous(step, limitId == ContinuousProcessIndex(IndexProcess2));
+        ret |= B_.doContinuous(
+            step, limitId == ContinuousProcessIndex(
+                                 reinterpret_cast<void const*>(std::addressof(B_))));
       }
     }
 
@@ -279,8 +283,9 @@ namespace corsika {
                       "getMaxStepLength(TParticle const&, TTrack const&)\" required for "
                       "ContinuousProcess<TDerived>. ");
 
-        ContinuousProcessStepLength const step(A_.getMaxStepLength(particle, vTrack),
-                                               ContinuousProcessIndex(IndexProcess1));
+        ContinuousProcessStepLength const step(
+            A_.getMaxStepLength(particle, vTrack),
+            ContinuousProcessIndex(reinterpret_cast<void const*>(std::addressof(A_))));
         max_length = std::min(max_length, step);
       }
     }
@@ -299,8 +304,9 @@ namespace corsika {
                       "getMaxStepLength(TParticle const&, TTrack const&)\" required for "
                       "ContinuousProcess<TDerived>. ");
 
-        ContinuousProcessStepLength const step(B_.getMaxStepLength(particle, vTrack),
-                                               ContinuousProcessIndex(IndexProcess2));
+        ContinuousProcessStepLength const step(
+            B_.getMaxStepLength(particle, vTrack),
+            ContinuousProcessIndex(reinterpret_cast<void const*>(std::addressof(B_))));
         max_length = std::min(max_length, step);
       }
     }
diff --git a/corsika/detail/framework/process/SwitchProcessSequence.inl b/corsika/detail/framework/process/SwitchProcessSequence.inl
index 0fbe23aac..ff81094f4 100644
--- a/corsika/detail/framework/process/SwitchProcessSequence.inl
+++ b/corsika/detail/framework/process/SwitchProcessSequence.inl
@@ -99,7 +99,9 @@ namespace corsika {
         //            "doContinuous(TParticle[const]&,TTrack[const]&,bool)\" required for
         //            " "ContinuousProcess<TDerived>. ");
 
-        return A_.doContinuous(step, idLimit == ContinuousProcessIndex(IndexProcess1));
+        return A_.doContinuous(
+            step, idLimit == ContinuousProcessIndex(
+                                 reinterpret_cast<void const*>(std::addressof(A_))));
       }
     } else {
       if constexpr (process2_type::is_process_sequence) {
@@ -120,7 +122,9 @@ namespace corsika {
         //            "doContinuous(TParticle [const]&,TTrack[const]&,bool)\" required for
         //            " "ContinuousProcess<TDerived>. ");
 
-        return B_.doContinuous(step, idLimit == ContinuousProcessIndex(IndexProcess2));
+        return B_.doContinuous(
+            step, idLimit == ContinuousProcessIndex(
+                                 reinterpret_cast<void const*>(std::addressof(B_))));
       }
     }
     return ProcessReturn::Ok;
@@ -184,8 +188,9 @@ namespace corsika {
                       "getMaxStepLength(TParticle const&, TTrack const&)\" required for "
                       "ContinuousProcess<TDerived>. ");
 
-        return ContinuousProcessStepLength(A_.getMaxStepLength(particle, vTrack),
-                                           ContinuousProcessIndex(IndexProcess1));
+        return ContinuousProcessStepLength(
+            A_.getMaxStepLength(particle, vTrack),
+            ContinuousProcessIndex(reinterpret_cast<void const*>(std::addressof(A_))));
       }
     } else {
       if constexpr (process2_type::is_process_sequence) {
@@ -200,8 +205,9 @@ namespace corsika {
                       "getMaxStepLength(TParticle const&, TTrack const&)\" required for "
                       "ContinuousProcess<TDerived>. ");
 
-        return ContinuousProcessStepLength(B_.getMaxStepLength(particle, vTrack),
-                                           ContinuousProcessIndex(IndexProcess2));
+        return ContinuousProcessStepLength(
+            B_.getMaxStepLength(particle, vTrack),
+            ContinuousProcessIndex(reinterpret_cast<void const*>(std::addressof(B_))));
       }
     }
 
diff --git a/corsika/framework/process/ContinuousProcessIndex.hpp b/corsika/framework/process/ContinuousProcessIndex.hpp
index 7192b86bf..6898633e9 100644
--- a/corsika/framework/process/ContinuousProcessIndex.hpp
+++ b/corsika/framework/process/ContinuousProcessIndex.hpp
@@ -19,16 +19,16 @@ namespace corsika {
   class ContinuousProcessIndex {
   public:
     ContinuousProcessIndex()
-        : id_(-1) {} // default
-    ContinuousProcessIndex(int const id)
+        : id_(nullptr) {} // default
+    ContinuousProcessIndex(void const* id)
         : id_(id) {}
-    void setIndex(int const id) { id_ = id; }
-    int getIndex() const { return id_; }
+    void setIndex(void const* id) { id_ = id; }
+    void const* getIndex() const { return id_; }
     bool operator==(ContinuousProcessIndex const v) const { return id_ == v.id_; }
-    bool operator!=(ContinuousProcessIndex const v) const { return id_ != v.id_; }
+    bool operator!=(ContinuousProcessIndex const v) const { return !(*this == v); }
 
   private:
-    int id_;
+    void const* id_;
   };
 
 } // namespace corsika
-- 
GitLab