Technically yes – maybe even
Container::max_size in general should be
static.
That’s an ABI break though and as there is a valid workaround (tuple_size)
I’m not sure fixing this would have priority (let alone consensus) in LEWG…
@Jake: not sure what you mean with "or have the ability to have static methods that provide a static interface and a non-static interface." as we already have
that, arr.size() would still work if size was
static…
From: Std-Proposals <std-proposals-bounces@lists.isocpp.org>
On Behalf Of Filippo Casarin via Std-Proposals
Sent: Saturday, June 13, 2020 12:54 AM
To: std-proposals@lists.isocpp.org
Cc: Filippo Casarin <casarin.filippo17@gmail.com>
Subject: [std-proposals] std::array::size should be static
With the current c++20 standard the following code
#include <array>
struct S {
std::array<int, 4> arr;
void foo() {
static_assert(arr.size());
}
};
generate this error
main.cpp: In member function ‘void S::foo()’:
main.cpp:7:31: error: non-constant condition for static assertion
7 | static_assert(arr.size());
| ~~~~~~~~^~
main.cpp:7:31: error: use of ‘this’ in a constant expression
This would work if std::array::size would be static, also I don't think any old code would break for this change.
std::array::max_size and std::array::empty are similar and I think should be static.