Sfoglia il codice sorgente

new operator() for Value class

Eric Ramat 1 anno fa
parent
commit
b15d0d00b2
1 ha cambiato i file con 11 aggiunte e 0 eliminazioni
  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);
   }
 
+  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>
   void operator()(std::vector<T> &value) const {
     dynamic_cast<Data<T> *>(_data.get())->operator()(value);