-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement order_by() #10
Comments
Hi Phillip, thanks a lot for working on this! Here's a toy program to think about:
What should the values of
We can consider this a test case for the library, since it really ought to work this way. I see two issues: first Try to mimick the implementation of other fundamental operations (for example, |
Additionally think about this:
How will you end up performing only a single |
Ok, I have started to understand a bit more how enumerables and enumerators are working. I have come up with the following solution which has deferred processing and implements "then_by" as well. What do you think?
|
This looks great. I have a few comments/questions:
|
regarding 1) As far as I understand, the library does not move the vector. The from_enumerable specialization for Range& is used in the test case we have here (just tested with MS VC 2013, will test with GCC next week). This specialization stores a reference to the vector. regarding 2) you get a compiler error because from_enumerable<..> does not have (public) typedefs for source_type and compare_type. Note I have added the "enumerable_type2" template argument just to avoid that compiler error for non "interactive<order_by<...>>". SFINAE only applies if the deduction depends on a template argument. Maybe there is a nicer trick to do that. Adding
produces the desired error message for linq::from(points).then_by(...). regarding 3: this test is ok:
regarding 4: this was copy-pasted from your code :-) |
Great work on all of this! You're right about point 2. Regarding point 4, you copy pasted it from me 2 years ago when I didn't know about that use of the delete keyword. Hahaha Go ahead and make a pull request. If I recall correctly, I have Travis CI set up to build MSVC, GCC, and clang. I'll have to update the readme to reflect what is currently implemented.
|
I tried implementing the order_by but got lost in template magic
I guess the approach that came closest to zero-compiler-errors-state was
the following, even though it's not very efficient.
Do you have a hint how to correctly derive the return type of that function?
The text was updated successfully, but these errors were encountered: