martinmoene / span-lite

span lite - A C++20-like span for C++98, C++11 and later in a single-file header-only library
Boost Software License 1.0
495 stars 40 forks source link

Inconsitent behaviors with C array and make_span return type #60

Open fmatthew5876 opened 3 years ago

fmatthew5876 commented 3 years ago

Hello, please see the following:

static_assert(std::is_same<decltype(make_span(std::declval<int[5]>())),span<const int>>::value, "make_span Broken");
static_assert(std::is_same<decltype(make_span(std::declval<int(&)[5]>())),span<int,5>>::value, "make_span Broken");
static_assert(std::is_same<decltype(make_span(std::declval<const int[5]>())),span<const int,5>>::value, "make_span Broken");
static_assert(std::is_same<decltype(make_span(std::declval<const int(&)[5]>())),span<const int,5>>::value, "make_span Broken");

The first case returns a span with dynamic extent, while the other 3 return a span with a fixed size extent.

While non-const rvalue reference to C arrays almost never appear anywhere, this is a minor inconsistency and looks like a bug?

martinmoene commented 2 years ago

Above code in Compiler explorer.