C++ Logo

std-proposals

Advanced search

[std-proposals] Should `std::array<T, 0>` be `view`?

From: Hewill Kang <hewillk_at_[hidden]>
Date: Fri, 24 May 2024 00:39:37 +0800
The standard specifies a legal case for `std::array` where `N` is `0`. It
seems to me that `array<T, 0>` always meets the semantic requirements of
`ranges::view`.
I'm wondering if there is value in making it a `view` since it behaves very
similarly to `views::empty<T>`? For example:

template<class T>
constexpr bool ranges::enable_view<array<T, 0>> = true;
template<class T>
constexpr bool ranges::enable_borrowed_range<array<T, 0>> = true;

Is this reasonable or is this just a bad idea?

Hewill

Received on 2024-05-23 16:39:50