Refactor IndexedView

Reference issue

What does this implement/fix?

Refactor code to minimize verbosity of SFINAE in public API and make it easier to debug and maintain. Re-enable raw, fixed-size array access.

Typical operator() overload before:

template <typename RowIndices, typename ColIndices>
std::enable_if_t<internal::valid_indexed_view_overload<RowIndices, ColIndices>::value &&
                     internal::traits<IndexedViewType<RowIndices, ColIndices>>::ReturnAsBlock,
                 typename internal::traits<IndexedViewType<RowIndices, ColIndices>>::BlockType>
operator()(const RowIndices& rowIndices, const ColIndices& colIndices) {
  typedef typename internal::traits<IndexedViewType<RowIndices, ColIndices>>::BlockType BlockType;
  IvcRowType<RowIndices> actualRowIndices = ivcRow(rowIndices);
  IvcColType<ColIndices> actualColIndices = ivcCol(colIndices);
  return BlockType(derived(), internal::first(actualRowIndices), internal::first(actualColIndices),
                   internal::index_list_size(actualRowIndices), internal::index_list_size(actualColIndices));
}

After:

template <typename RowIndices, typename ColIndices, EnableOverload<RowIndices, ColIndices> = true>
IndexedViewType<RowIndices, ColIndices> operator()(const RowIndices& rowIndices, const ColIndices& colIndices) {
  return IndexedViewSelector<RowIndices, ColIndices>::run(derived(), rowIndices, colIndices);
}

Additional information

Edited by Charles Schlosser

Merge request reports

Loading