message: use universal references for for_each Functors, only use one base version
diff: @@ -37,6 +37,19 @@ namespace ospcommon {
  return idx.x + size_t(dims.x) * (idx.y + size_t(dims.y) * idx.z);
  }
  + /*! iterate through all indices in [lower,upper), EXCLUSING the
  + 'upper' value */
  + template <typename Functor>
  + inline void for_each(const vec3i &lower,
  + const vec3i &upper,
  + Functor &&functor)
  + {
  + for (int iz = lower.z; iz < upper.z; iz++)
  + for (int iy = lower.y; iy < upper.y; iy++)
  + for (int ix = lower.x; ix < upper.x; ix++)
  + functor(vec3i(ix, iy, iz));
  + }
  +
  /*! a template that calls the given functor (typically a lambda) for
  every vec3i(ix,iy,iz) with 0<=ix<xize.x, 0<=iy<size.y, and
  0<=iz<size.z)
  @@ -44,37 +57,21 @@ namespace ospcommon {
  Example:
  array3D::for_each(volume->size(),[&](const vec3i &idx){
  - domeSomeThing(volume,index);
  + doSomeThing(volume,index);
  });
  */
  template <typename Functor>
  - inline void for_each(const vec3i &size, const Functor &functor)
  + inline void for_each(const vec3i &size, Functor &&functor)
  {
  - for (int iz = 0; iz < size.z; iz++)
  - for (int iy = 0; iy < size.y; iy++)
  - for (int ix = 0; ix < size.x; ix++)
  - functor(vec3i(ix, iy, iz));
  - }
  -
  - /*! iterate through all indices in [lower,upper), EXCLUSING the
  - 'upper' value */
  - template <typename Functor>
  - inline void for_each(const vec3i &lower,
  - const vec3i &upper,
  - const Functor &functor)
  - {
  - for (int iz = lower.z; iz < upper.z; iz++)
  - for (int iy = lower.y; iy < upper.y; iy++)
  - for (int ix = lower.x; ix < upper.x; ix++)
  - functor(vec3i(ix, iy, iz));
  + for_each({0, 0, 0}, size, std::forward<Functor>(functor));
  }
  /*! iterate through all indices in [lower,upper), EXCLUSING the
  'upper' value */
  template <typename Functor>
  - inline void for_each(const box3i &coords, const Functor &functor)
  + inline void for_each(const box3i &coords, Functor &&functor)
  {
  - for_each(coords.lower, coords.upper, functor);
  + for_each(coords.lower, coords.upper, std::forward<Functor>(functor));
  }
  } // ::ospcommon::array3D
  