message: use index_sequence to collapse loops
diff: // ospray
  #include "Data.h"
  #include "ospray/ospray.h"
  +// ospcommon
  +#include "ospcommon/utility/multidim_index_sequence.h"
  namespace ospray {
  @@ -43,8 +45,8 @@ namespace ospray {
  Data::Data(OSPDataType type, const vec3ui &numItems)
  : shared(false), type(type), numItems(numItems), byteStride(0)
  {
  - addr = (char *)alignedMalloc(
  - size() * sizeOf(type) + 16); // XXX padding needed?
  + addr = (char *)alignedMalloc(size() * sizeOf(type) +
  + 16); // XXX padding needed?
  init();
  if (isObjectType(type)) // XXX initialize always? or never?
  memset(addr, 0, size() * sizeOf(type));
  @@ -95,8 +97,8 @@ namespace ospray {
  }
  // finalize ispc-side
  ispc.addr = reinterpret_cast<decltype(ispc.addr)>(addr);
  - ispc.huge = ispc.byteStride * ispc.numItems
  - > std::numeric_limits<std::int32_t>::max();
  + ispc.huge = ispc.byteStride * ispc.numItems >
  + std::numeric_limits<std::int32_t>::max();
  }
  bool Data::compact() const
  @@ -106,29 +108,34 @@ namespace ospray {
  void Data::copy(const Data &source, const vec3ui &destinationIndex)
  {
  - if (type != source.type
  - && !(type == OSP_OBJECT && isObjectType(source.type)))
  - throw std::runtime_error(toString()
  - + "::copy: types must match (cannot copy '" + stringFor(source.type)
  - + "' into '" + stringFor(type) + "')");
  - if (shared && !source.shared)
  + if (type != source.type &&
  + !(type == OSP_OBJECT && isObjectType(source.type))) {
  throw std::runtime_error(
  - "OSPData::copy: cannot copy opaque (non-shared) data into shared data");
  - if (anyLessThan(numItems, destinationIndex + source.numItems))
  + toString() + "::copy: types must match (cannot copy '" +
  + stringFor(source.type) + "' into '" + stringFor(type) + "')");
  + }
  +
  + if (shared && !source.shared) {
  + throw std::runtime_error(
  + "OSPData::copy: cannot copy opaque (non-shared) data into shared "
  + "data");
  + }
  +
  + if (anyLessThan(numItems, destinationIndex + source.numItems)) {
  throw std::out_of_range(
  "OSPData::copy: source does not fit into destination");
  + }
  - if (byteStride == source.byteStride
  - && data(destinationIndex) == source.data()) {
  + if (byteStride == source.byteStride &&
  + data(destinationIndex) == source.data()) {
  // NoOP, no need to copy identical region
  // TODO markDirty(destinationIndex, destinationIndex + source.numItems);
  return;
  }
  - vec3ui srcIdx;
  - for (srcIdx.z = 0; srcIdx.z < source.numItems.z; srcIdx.z++)
  - for (srcIdx.y = 0; srcIdx.y < source.numItems.y; srcIdx.y++)
  - for (srcIdx.x = 0; srcIdx.x < source.numItems.x; srcIdx.x++) {
  + index_sequence_3D srcIndices(source.numItems);
  +
  + for (auto srcIdx : srcIndices) {
  char *dst = data(srcIdx + destinationIndex);
  const char *src = source.data(srcIdx);
  if (isObjectType(type)) {
  @@ -139,10 +146,11 @@ namespace ospray {
  if (*dstO)
  (*dstO)->refDec();
  *dstO = *srcO;
  - } else
  + } else {
  memcpy(dst, src, sizeOf(type));
  }
  }
  + }
  std::string Data::toString() const
  {
  