Очень уменьшенный код для воспроизведения:
Код: Выделить всё
#include
#include
#include
#include
#include
#include
template
requires std::derived_from<
MDS, std::experimental::mdspan<
typename MDS::element_type, typename MDS::extents_type,
typename MDS::layout_type, typename MDS::accessor_type>>
class mdspan_extent_iterator {
private:
std::optional mdspan = std::nullopt;
typename MDS::index_type index = static_cast(0);
public:
typedef decltype(*std::declval) value_type;
const auto operator*() const {
return [](
const MDS &mdspan,
const std::integer_sequence,
typename MDS::index_type index,
const std::integer_sequence) {
return std::experimental::submdspan(
mdspan,
(static_cast(PRE_EXTENTS), std::experimental::full_extent)...,
index,
(static_cast(POST_EXTENTS), std::experimental::full_extent)...);
}(mdspan.value(),
std::make_integer_sequence{}, index,
std::make_integer_sequence{});
}
};
static_assert(requires {
typename std::iter_value_t,
1>>;
});
< /code>
К сожалению, это дает мне следующую ошибку: < /p>
In file included from /opt/compiler-explorer/gcc-14.2.0/include/c++/14.2.0/bits/stl_iterator_base_types.h:71,
from /opt/compiler-explorer/gcc-14.2.0/include/c++/14.2.0/bits/stl_iterator.h:64,
from /opt/compiler-explorer/gcc-14.2.0/include/c++/14.2.0/bits/ranges_base.h:37,
from /opt/compiler-explorer/gcc-14.2.0/include/c++/14.2.0/bits/ranges_util.h:34,
from /opt/compiler-explorer/gcc-14.2.0/include/c++/14.2.0/tuple:44,
from /opt/compiler-explorer/gcc-14.2.0/include/c++/14.2.0/functional:53,
from :2:
/opt/compiler-explorer/gcc-14.2.0/include/c++/14.2.0/bits/iterator_concepts.h: In substitution of 'template using std::__detail::__iter_value_t = typename std::__detail::__iter_traits_impl::type::value_type [with _Tp = mdspan_extent_iterator]':
/opt/compiler-explorer/gcc-14.2.0/include/c++/14.2.0/bits/iterator_concepts.h:302:11: required by substitution of 'template using std::iter_value_t = std::__detail::__iter_value_t [with _Tp = mdspan_extent_iterator]'
302 | using iter_value_t = __detail::__iter_value_t;
| ^~~~~~~~~~~~
:48:10: required from here
48 | 1>>;
| ^~
/opt/compiler-explorer/gcc-14.2.0/include/c++/14.2.0/bits/iterator_concepts.h:297:13: error: no type named 'value_type' in 'std::__detail::__iter_traits' {aka 'struct std::indirectly_readable_traits'}
297 | using __iter_value_t = typename
| ^~~~~~~~~~~~~~
Compiler returned: 1
Что я делаю не так?
Подробнее здесь: https://stackoverflow.com/questions/793 ... rator-clas