glenfe / span

Span
Boost Software License 1.0
2 stars 0 forks source link

`span` should be refactored to two class templates, `span` and `static_span` #2

Open cmazakas opened 3 years ago

cmazakas commented 3 years ago

A common complaint about std::span is that is usage of a NTTP for storage optimization is undesirable.

Refactoring so that span is a constant 2 word-sized class would appease complaints from multiple users.

static_span would also self-document better.

Both class templates should be interconvertible with one another.

glenfe commented 3 years ago

You could always do:

namespace my {

template<class T>
struct span
    : boost::spans::span<T> {
    using boost::spans::span<T>::span;
};

template<class T, std::size_t N>
struct static_span
    : boost::spans::span<T, N> {
    static_assert(N != boost::spans::dynamic_extent);
    using boost::spans::span<T, N>::span;
};

} // my