From cf96ad06a257877e3d9933636c444c08b08b12ec Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Tue, 15 Oct 2019 23:45:47 +0200
Subject: [PATCH] Add missing virtual destructor to ICFunctionEmbedder

Also check that given arguments list has the same size than the  C-function
arguments and revert to sin function for testing purpose
---
 src/language/CFunctionEmbedder.hpp                 | 3 +++
 src/language/node_processor/CFunctionProcessor.hpp | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/language/CFunctionEmbedder.hpp b/src/language/CFunctionEmbedder.hpp
index 5aa9fdf26..37852636b 100644
--- a/src/language/CFunctionEmbedder.hpp
+++ b/src/language/CFunctionEmbedder.hpp
@@ -12,6 +12,8 @@
 struct ICFunctionEmbedder
 {
   virtual void apply(const std::vector<ASTNodeDataVariant>& x, double& f_x) = 0;
+
+  virtual ~ICFunctionEmbedder() = default;
 };
 
 template <typename FX, typename... Args>
@@ -41,6 +43,7 @@ class CFunctionEmbedder : public ICFunctionEmbedder
   PUGS_INLINE void
   _copy_from_vector(ArgsTuple& t, const std::vector<ASTNodeDataVariant>& v, std::index_sequence<I...>) const
   {
+    Assert(sizeof...(Args) == v.size());
     (_copy_value<I>(t, v), ...);
   }
 
diff --git a/src/language/node_processor/CFunctionProcessor.hpp b/src/language/node_processor/CFunctionProcessor.hpp
index 4bbda59f9..15c56da81 100644
--- a/src/language/node_processor/CFunctionProcessor.hpp
+++ b/src/language/node_processor/CFunctionProcessor.hpp
@@ -58,8 +58,8 @@ class CFunctionExpressionProcessor final : public INodeProcessor
   CFunctionExpressionProcessor(ASTNode& node, std::vector<ASTNodeDataVariant>& argument_values)
     : m_node{node}, m_argument_values{argument_values}
   {
-    m_embedded_function = std::make_unique<CFunctionEmbedder<double, double, double>>(
-      std::function{[](double x, double y) -> double { return std::sin(x) * std::cos(3 * x) + y; }});
+    m_embedded_function = std::make_unique<CFunctionEmbedder<double, double>>(
+      std::function{[](double x) -> double { return std::sin(x); }});
   }
 };
 
-- 
GitLab