lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 44b780e 7/8: Deduce Eval()'s return type


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 44b780e 7/8: Deduce Eval()'s return type
Date: Sat, 20 Mar 2021 09:55:30 -0400 (EDT)

branch: master
commit 44b780e9579504c1ab43991d5f4f2c90878f6529
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Deduce Eval()'s return type
---
 et_vector_test.cpp             | 4 ++--
 tools/pete-2.1.1/et_vector.hpp | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/et_vector_test.cpp b/et_vector_test.cpp
index ae8a03c..fd8daa3 100644
--- a/et_vector_test.cpp
+++ b/et_vector_test.cpp
@@ -58,8 +58,8 @@ int test_main(int, char*[])
     {
     std::vector<double> v0 = {1.0, 1.25, 1.5};
     std::vector<double> v1 = {0.0, 0.25, 0.5};
-    std::vector<double> const x = Eval<double>(v0 + v1);
-    auto                const y = Eval<double>(v0 + v1 + x);
+    std::vector<double> const x = Eval(v0 + v1);
+    auto                const y = Eval(v0 + v1 + x);
     std::vector<double> const r0 = {1.0, 1.5, 2.0};
     LMI_TEST(r0 == x);
     std::vector<double> const r1 = {2.0, 3.0, 4.0};
diff --git a/tools/pete-2.1.1/et_vector.hpp b/tools/pete-2.1.1/et_vector.hpp
index 78fb1f6..699adb6 100644
--- a/tools/pete-2.1.1/et_vector.hpp
+++ b/tools/pete-2.1.1/et_vector.hpp
@@ -198,11 +198,12 @@ inline void evaluate(std::vector<T>& t, Op const& op, 
Expression<U> const& u)
         }
 }
 
-template<typename T, typename U>
-inline std::vector<T> Eval(Expression<U> const& u)
+template<typename U>
+inline auto Eval(Expression<U> const& u)
 {
     int const n {Rho(u)};
-    std::vector<T> z;
+    using Deduced = decltype(forEach(u, EvalLeaf1(0), OpCombine()));
+    std::vector<Deduced> z;
     z.reserve(n);
     for(int i = 0; i < n; ++i)
         {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]