Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Counterpoint: C++ expression templates have existed for a long time, and require no explicit work on the user side. They are incredibly unwieldy to write and debug though.


I am gonna be completely honest, I have never quite been able to understand expression templates properly. is it possible to use them to get hassle-free laziness? is there any example of a library that does this (just to look at it and see how it's done)?


Define hassle-free. In readability of user code? Yes. In getting clean compiler errors? No.

One example would be Eigen: https://eigen.tuxfamily.org/index.php?title=Main_Page

See also their page on lazy evaluation: https://eigen.tuxfamily.org/dox/TopicLazyEvaluation.html

Of course, C++ is powerful enough that using specific tools can make the expression template abstraction fall apart (e.g. auto), but fundamentally you can write matrix code very cleanly and get great lazy-evaluated performance.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: