Parcourir la source

new operator() for Value class

Eric Ramat il y a 1 an
Parent
commit
b15d0d00b2
1 fichiers modifiés avec 11 ajouts et 0 suppressions
  1. 11 0
      src/artis-star/common/event/Value.hpp

+ 11 - 0
src/artis-star/common/event/Value.hpp

@@ -199,6 +199,17 @@ public:
     dynamic_cast<Data<T> *>(_data.get())->operator()(value);
     dynamic_cast<Data<T> *>(_data.get())->operator()(value);
   }
   }
 
 
+  template<typename T>
+  void operator()(T *&value) const {
+    const std::valarray<T>& array = std::any_cast<const std::valarray<T>&>(*dynamic_cast<Data<T> *>(_data.get()));
+    unsigned int index = 0;
+
+    value = new T[size()];
+    for (const auto& e: array) {
+      value[index++] = e;
+    }
+  }
+
   template<typename T>
   template<typename T>
   void operator()(std::vector<T> &value) const {
   void operator()(std::vector<T> &value) const {
     dynamic_cast<Data<T> *>(_data.get())->operator()(value);
     dynamic_cast<Data<T> *>(_data.get())->operator()(value);