C++ Logo

std-discussion

Advanced search

[linalg.algs.blas1.iamax] `vector_idx_abs_max` declared to return `extents_type` but Returns says a scalar `size_type` index

From: Abhinav Agarwal <abhinavagarwal1996_at_[hidden]>
Date: Fri, 5 Jun 2026 07:46:41 -0700
Hello,

While reading the `<linalg>` wording in N5050, I noticed what looks like a
type mismatch in `vector_idx_abs_max` (`IxAMAX`).

Both overloads are declared, in `[linalg.syn]` and again in
`[linalg.algs.blas1.iamax]`, as:

```
template<in-vector InVec>
  typename InVec::extents_type vector_idx_abs_max(InVec v);
```

But the Returns clause specifies a scalar index:

> - `numeric_limits<typename InVec::size_type>::max()` if `v` has zero
elements;
> - otherwise, the index of the first element of `v` having largest
absolute value ...

For an `in-vector`, `InVec` is a rank-1 `mdspan`, so `InVec::extents_type`
is a `std::extents<...>` shape type, while `InVec::size_type` is an
unsigned integer. I don't see how the specified result can be an
`extents_type`: the wording names a scalar index, and the empty-case
sentinel explicitly uses `size_type`.

The Kokkos stdBLAS reference implementation and cpprefjp both use a scalar
return type, which makes me suspect `extents_type` is a slip for
`size_type` in the four declaration sites.

There may still be a `size_type`-vs-`index_type` question, but either way
the return seems like it should be scalar, not `extents_type`.

Am I misreading this, or does it look like an LWG issue?

Thanks,
-- Abhinav Agarwal

Received on 2026-06-05 14:47:10