Open frederick-vs-ja opened 1 year ago
BTW, I don't see how std::get
overloads can work for program-defined specializations of std::tuple
, but these specializations seem to be allowed.
BTW, I don't see how
std::get
overloads can work for program-defined specializations ofstd::tuple
, but these specializations seem to be allowed.
Yes, std::get
is unimplementable for program-defined specializations of tuple
- I think this is relatively well-known. Feel free to submit an LWG issue.
unsigned char dummy_[1];
Completely unrelated to the issue: I think you can use a base class (template <class> struct _Empty_array_base {};
) or [[no_unique_address]]
member (struct _DummyTy {}; [[no_unique_address]] _DummyTy _Dummy;
) of a unique empty aggregate class type to make array<T, 0>
initializable with both {}
and {{}}
while still keeping it empty.
We talked about this at the weekly maintainer meeting. While this sort of thing (tolerating program-defined specializations of STL types that depend on program-defined element types) is allowed by the Standard and therefore is technically a bug in our implementation, in practice replacing std::array
etc. is so much work that we never see users doing this. At most, helper types like std::less
and std::hash
are specialized by users, but not the larger containers etc.
We'll keep this issue open because we don't like wontfixing things that are conformance bugs. However, with the major backlog of user-relevant bugs and other issues, and maintainer capacity constraints for the foreseeable future, we would like to gently discourage further PRs that work towards supporting program-defined specializations like this. Thanks for understanding :sweat_smile:
Describe the bug
The following program is rejected when using MSVC STL (in C++23 mode), while the program-defined specializations of
std::array
seem to be well-defined.Command-line test case
Godbolt link
Expected behavior
The program compiles. For program-defined container specializations, comparison operators should not call
_Unchecked_begin
/_Unchecked_end
.For contiguous containers/views, it seems OK to unconditionally call member
data
andsize
. For other containers, it may be needed to fall back tobegin
/end
when_Unchecked_begin
/_Unchecked_end
are unavailable.STL version
Additional context