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
3
u/Negitivefrags Jun 27 '26
For MSVC at least you can use [[msvc::intrinsic]] to make the compiler inline the call in the compiler frontend which happens even in debug mode. On second thoughts, maybe it doesn't apply in this case since it's not just a cast.