[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)
{
- [lmi-commits] [lmi] master updated (1be41b7 -> 1d15a4a), Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master d5f870a 1/8: Improve documentation, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master 4220f5e 2/8: Assume default allocator always, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master 44b780e 7/8: Deduce Eval()'s return type,
Greg Chicares <=
- [lmi-commits] [lmi] master de67a28 5/8: Improve an error message, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master cd6c9ea 3/8: Favor the One True type-parameter-key, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master 4c4a0e4 4/8: Add a PETE length-of function, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master 1d15a4a 8/8: Isolate PETE directory weirdness to a redirection header, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master 334ac64 6/8: Add a function template to transform a PETE expression to a std::vector, Greg Chicares, 2021/03/20