Skip to content

Support for std::span for winrt::array_view and winrt::com_array - #1343

Merged
Jon Wiswall (jonwis) merged 8 commits into
microsoft:masterfrom
jonwis:user/jonwis/update-juv-studios
Aug 28, 2023
Merged

Support for std::span for winrt::array_view and winrt::com_array#1343
Jon Wiswall (jonwis) merged 8 commits into
microsoft:masterfrom
jonwis:user/jonwis/update-juv-studios

Conversation

@jonwis

Copy link
Copy Markdown
Member

This fixes #1289 per "option C" by completing what #1331 started.

  • Constructors for both array_view and com_array that take a span
  • Conversions on both array_view and com_array that produce a span
  • Tests for the conversions and constructions
  • Additional ctad support for easy use

@JaiganeshKumaran thank you for the initial start - see if this meets your needs, please.

Comment thread test/test_cpp20/array_span.cpp
Comment thread strings/base_array.h
@kennykerr

Copy link
Copy Markdown
Collaborator

Hopefully Ryan Shepherd (@DefaultRyan) can spare a few minutes to look this over. He probably has the best handle on the standard library best practices.

Comment thread strings/base_array.h Outdated

@kennykerr Kenny Kerr (kennykerr) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I still think the lifetime here is bonkers, but admittedly not any worse than the C++ standard library.

@jonwis
Jon Wiswall (jonwis) merged commit 691f6f8 into microsoft:master Aug 28, 2023
@jonwis
Jon Wiswall (jonwis) deleted the user/jonwis/update-juv-studios branch August 28, 2023 17:24
@dmachaj

Copy link
Copy Markdown
Contributor

Sorry I'm a little late to the party. Do these new methods affect vtable layout at all? In other words, does span support need an ODR pragma to prevent mismatches?

@kennykerr

Copy link
Copy Markdown
Collaborator

Do these new methods affect vtable layout at all?

std::span is not an ABI type.

@jonwis

Copy link
Copy Markdown
Member Author

It's pure conversion methods; no change to the layout or functionality of array_view or com_array here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow passing array_view as span

5 participants