Thanks, Edward. I keep mistakenly thinking that "expression template
library" is a sufficient explanation on the Boost list, even though I know
that this is not the case.
Yap allows you to capture a C++ expression as an expression tree that can
be subsequently transformed and/or evaluated. For instance, here is some
end-user code using lazy vectors. The lazy_vector type and the associated
operations are defined using the Yap library. This is mostly a copy-paste
from one of the Yap examples, here:
https://tzlaine.github.io/yap/doc/html/boost_yap__proposed_/manual/examples/...
int main ()
{
// A lazy vector contains a std::vector<double> value
lazy_vector v1{std::vector<double>(4, 1.0)};
lazy_vector v2{std::vector<double>(4, 2.0)};
lazy_vector v3{std::vector<double>(4, 3.0)};
// This statement does not create a temporary vector, and
// only uses the elements v2[2] and v3[2]. It also generates
// the exact same object code as "x2[2] + x3[2]", where x2
// and x3 are non-lazy, plain old std::vector<double>s.
double d1 = (v2 + v3)[2];
std::cout << d1 << "\n";
// This statement does an element-wise operation, creating
// no temporaries.
v1 += v2 - v3;
std::cout << '{' << v1[0] << ',' << v1[1]
<< ',' << v1[2] << ',' << v1[3] << '}' << "\n";
// This expression is disallowed because it does not conform to the
// implicit grammar. operator+= is only defined on terminals, not
// arbitrary expressions.
// (v2 + v3) += v1;
return 0;
}
The Yap code that you must write in order to make this end-user code work
is fairly small:
// This transform turns a terminal of std::vector<double> into a terminal
// containing the nth double in that vector. Think of it as turning our
// expression of vectors into an expression of scalars.
struct take_nth
{
boost::yap::terminal
On 3/18/2017 6:55 PM, Zach Laine via Boost wrote:
I posted 2-3 months ago about Yap, an expression template library I've written that I intend to propose for Boost.
This is just a reminder that the library exists, and where to find it.
I'm giving a talk about it at C++Now 2017, and some time after that I intend to submit it to the queue. Louis Dionne has offered to serve as review manager when the time comes.
You can find the main repo on GitHub:
https://github.com/tzlaine/yap
And online docs are here:
You might want to mention here what the purpose of the library is and when it might be used by developers, in order to interest others.
Zach
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman /listinfo.cgi/boost