r/cpp • u/Odd_Comparison3831 • Jun 26 '26
projections for stl data structures
using projection in ranges::sort has removed the need write a compartor function or a lambda and is much easier to implement in my opinion
there should exists a similar feature for say sets or priority queues
would be wonnderful if I could just write
priority_queue<Student, Student::marks> for example
21
Upvotes
View all comments
Show parent comment
1
u/kal_at_kalx_net Jul 05 '26
I will go further: using projections as arguments to `std::ranges` functions was a fundamental design mistake. The Linq approach builds an AST that can provide more information to optimizing compilers. This thread is just another artifact of that original design mistake.
Stepanov thinks `std::ranges` is too complicated. He is right.