Skip to content

LWG-3850: views::as_const on empty_view<T> should return empty_view<const T> - #3423

Merged
Stephan T. Lavavej (StephanTLavavej) merged 4 commits into
microsoft:mainfrom
JMazurkiewicz:lwg3850
Feb 14, 2023
Merged

LWG-3850: views::as_const on empty_view<T> should return empty_view<const T>#3423
Stephan T. Lavavej (StephanTLavavej) merged 4 commits into
microsoft:mainfrom
JMazurkiewicz:lwg3850

Conversation

@JMazurkiewicz

Copy link
Copy Markdown
Contributor

Closes #3418.

@CaseyCarter Casey Carter (CaseyCarter) added LWG Library Working Group issue ranges C++20/23 ranges labels Feb 12, 2023
Comment thread stl/inc/ranges Outdated
const same_as<iterator_t<R>> auto i = r.begin();
if (!is_empty) {
// (static analyzer doesn't realize that `i == nullptr` implies `is_empty`)
#pragma warning(suppress : 6011) // Dereferencing NULL pointer 'i'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change requested: We avoid suppress in stl/inc (as it sometimes has issues with templates and/or modules, whereas push/disable/pop is reliable) but it's fine in stl/src and test code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was concerned about empty_view<int&> being wrong, but it turns out that empty_view<reference-type> is invalid.

@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit f8dd9d1 into microsoft:main Feb 14, 2023
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for helping the list of remaining LWG issues get closer to empty! 😹 📉 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LWG Library Working Group issue ranges C++20/23 ranges

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LWG-3850 views::as_const on empty_view<T> should return empty_view<const T>

4 participants