title: Lazy evaluation in C++
body: <p>C++ does not have native support for lazy evaluation (as Haskell does).</p>
  
  <p>I'm wondering if it is possible to implement lazy evaluation in C++ in a reasonable manner. If yes, how would you do it?</p>
  
  <p>EDIT: I like Konrad Rudolph's answer.</p>
  
  <p>I'm wondering if it's possible to implement it in a more generic fashion, for example by using a parametrized class lazy that essentially works for T the way matrix_add works for matrix.</p>
  
  <p>Any operation on T would return lazy instead. The only problem is to store the arguments and operation code inside lazy itself. Can anyone see how to improve this?</p>