![]() |
STD-PROPOSALS |
Subject: Re: [std-proposals] std::array::size should be static
From: Michael Hava (mfh_at_[hidden])
Date: 2020-06-14 15:40:42
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_at_[hidden]> On Behalf Of Filippo Casarin via Std-Proposals
Sent: Saturday, June 13, 2020 12:54 AM
To: std-proposals_at_[hidden]
Cc: Filippo Casarin <casarin.filippo17_at_[hidden]>
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.
STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org