Existing methods to emulate C# concept of deferred IEnumerable<T> in C++? -
I'm looking to implement something similar to the deferred IEnumerable concept in C ++, but without template implementation . (My question is very similar, breaking the deal, leaving the templates.)
In our code, we have several functions that query a query, and the results passed std :: vector & Store in amp. ;; Often these functions are called lower-level versions that filter themselves and combine with other sets. Sometimes they will create local vectors (with different temporary allocations) to call lower-level functions, then after filtering the collar vector, push_back will not be normal functions, either in words or in spirit.
I am trying to eliminate copies and allocos, and result container is also needed. Plus when I'm doing this, I want to give it a short circuit capability.
There is a clear requirement of the suspended action here. In C #, it will be easy. Everything yields in an IEnumerable, and where () operators etc, use all deferred.
I know how to do this in C ++, going through the callback instead of the containers, we need to empower "push_back", as well as a refund for "stop here" Hui Bull Callback will be chained similarly to INNmable operators, although in operation it can be more of a push-pull, and probably will feel a bit like IObservable.
And above all of this, I have to save the template to implement these functional implementations I do not want to refocate a lot of code, and I do not want to run on unsupported compiler surprises on 15 or so different platforms, which We are currently compiling. So no promise, no (I think). And no C ++ 11
It looks like a solution problem, but I've poked around Google and probably could not find the right way to ask if this problem has already been solved?
I am rereading your question and in fact it seems that it can be helpful, but This is definitely not ideal without C ++ 11.
You can add boost :: function and lieutenant; Promotion: Optional & gt;
(yay boost) can see as a limitation The vocabulary of this category is super simple - you apply it, and when it is complete, it returns an empty alternative instead of the value.
For output functions such as push_back
, you boost :: function and lieutenant; Zero (t)> gt;
, which will accept the value and then whatever you need it with, though generally, these are not useful, because most functions can be written as modified ranges, then caller Instead of requiring that range to directly take an output limit, it can be used.
Here is a total bitch, but you can see in eg Boost.Phoenix / Lambda to help.
Comments
Post a Comment