Date: Sat, 13 Jun 2020 06:58:12 +0100
Abi break :)
On Sat, Jun 13, 2020, 06:53 codusnocturnus via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Not sure what the use case is, but std::tuple_size can fill in for all 3
> of those with std::array.
>
> #include <array>
> struct S {
> std::array<int, 4> arr;
>
> void foo() {
> // arr.size() == arr.max_size()
> // arr.size() != 0 -> !arr.empty()
> static_assert(std::tuple_size<decltype(arr)>::value);
> }
> };
>
>
> Sent with ProtonMail <https://protonmail.com> Secure Email.
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Friday, June 12, 2020 3:54 PM, Filippo Casarin via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
> 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 mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
On Sat, Jun 13, 2020, 06:53 codusnocturnus via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Not sure what the use case is, but std::tuple_size can fill in for all 3
> of those with std::array.
>
> #include <array>
> struct S {
> std::array<int, 4> arr;
>
> void foo() {
> // arr.size() == arr.max_size()
> // arr.size() != 0 -> !arr.empty()
> static_assert(std::tuple_size<decltype(arr)>::value);
> }
> };
>
>
> Sent with ProtonMail <https://protonmail.com> Secure Email.
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Friday, June 12, 2020 3:54 PM, Filippo Casarin via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
> 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 mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2020-06-13 01:01:34