From 8d6b26ff44285d644d8983e187ca23e5903b5722 Mon Sep 17 00:00:00 2001
From: Thibault Hallouin <thibault.hallouin@inrae.fr>
Date: Tue, 31 Jan 2023 08:22:07 +0100
Subject: [PATCH] template function to avoid unnecessary copy

---
 include/evalhyd/detail/masks.hpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/evalhyd/detail/masks.hpp b/include/evalhyd/detail/masks.hpp
index daee3e2..7a818ba 100644
--- a/include/evalhyd/detail/masks.hpp
+++ b/include/evalhyd/detail/masks.hpp
@@ -165,10 +165,11 @@ namespace evalhyd
         }
 
         /// Function to generate temporal mask based on masking conditions
+        template<class X1, class X2>
         inline xt::xtensor<bool, 1> generate_mask_from_conditions(
                 const std::array<char, 32>& msk_char_arr,
-                const xt::xtensor<double, 1>& q_obs,
-                const xt::xtensor<double, 2>& q_prd = {}
+                const X1& q_obs,
+                const X2& q_prd
         )
         {
             // parse string to identify masking conditions
@@ -200,7 +201,7 @@ namespace evalhyd
                     auto get_q = [&]() {
                         if (var == "q_obs")
                         {
-                            return q_obs;
+                            return xt::xtensor<double, 1>(q_obs);
                         }
                         else if (var == "q_prd_median")
                         {
-- 
GitLab