Suppose I have two std::vectors x and y and a binary function F. I would like to create a new object z (not necessarily a vector), with the property that the ith elemenent of z will be the application of F to the ith elements of x and y. For the time being I use
boost::range::transform(x, y, z.begin(), F)
which of course requires memory allocation for z. My goal however is to avoid this memory allocation and have the transformation lazy evaluated, similarly to what boost::adaptors::transformed does with unary functions. In other words, the type of z would be some type of boost::range. Is there any easy way to do this or would I have to write my own range class? Thanks in advance!