On Saturday, 4 June 2016 at 15:43:01 UTC, Mihail K wrote:
As far as I recall, foreach_reverse is deprecated in favour of range operations.
ie.

  import std.algorithm, std.range;

  static if(forward)
  {
      items.each!(item => doStuff());
  }
  else
  {
      items.retro.each!(item => doStuff());
  }

As for your question, I suggest writing a range function that calls retro conditionally. Something like,

  items.direction!(forward).each!(item => doStuff());

Won't this pattern fail if items is a type implementing opApply and/or opApplyReverse?

Reply via email to