Skip to content

winrt::array_view lacks a public (pointer, size) constructor #665

@dfields-msft

Description

@dfields-msft

In my experience, I typically have a pointer and size in hand, rather than begin/end pair, and have to repeat the pointer in the second argument and manually add the size to it to emulate begin/end semantics, just for array_view to subtract these again to pass to the private constructor. I always wish I could just say (pointer, size) instead. Concretely:

void ArrayViewExample(uint8_t* buffer, uint32_t size)
{
    for (const auto& byte : winrt::array_view(buffer, buffer + size)) { /* ... */ }
 
    // vs
 
    for (const auto& byte : winrt::array_view(buffer, size)) { /* ... */ }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions