Skip to content

Add CopyFrom methods to GenericArrayView for C++ container support#105

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/support-array-from-cpp-container
Draft

Add CopyFrom methods to GenericArrayView for C++ container support#105
Copilot wants to merge 4 commits intomasterfrom
copilot/support-array-from-cpp-container

Conversation

Copy link

Copilot AI commented Dec 6, 2025

Adds the ability to copy data to an Emboss array from C++ containers like std::vector or std::array.

Changes

  • CopyFrom: Copies from another GenericArrayView or any iterable C++ container
  • UncheckedCopyFrom: Same as above without bounds/validity checks
  • TryToCopyFrom: Returns false on size mismatch or element write failure

Uses SFINAE to disambiguate between view and container overloads.

Example

std::uint8_t bytes[4] = {0};
auto array_view = ArrayView<FixedUIntView<8>, ReadWriteContiguousBuffer, 1>{
    ReadWriteContiguousBuffer{bytes, sizeof bytes}};

// Copy from std::vector
std::vector<uint8_t> source = {1, 2, 3, 4};
array_view.CopyFrom(source);

// Copy from std::array
std::array<uint8_t, 4> arr = {{10, 20, 30, 40}};
array_view.CopyFrom(arr);

// Conditional copy (returns false if container too short)
std::vector<uint8_t> short_src = {1, 2};
bool ok = array_view.TryToCopyFrom(short_src);  // false

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.googleapis.com
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 --version (dns block)
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 version (dns block)
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 test //runtime/cpp/test:emboss_array_view_test --test_output=errors (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Support Setting an Array from C++ Container</issue_title>
<issue_description>This issue was copied from the upstream repository google/emboss.

Original issue: google#33
Original state: open, created at: 2022-02-15T23:17:13Z, updated at: 2022-02-15T23:19:10Z, by @reventlov


Original description

It would be convenient to be able to copy to/from an Emboss array from/to a C++ container, such as a std::vector.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 6, 2025 01:23
…ArrayView

Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Copilot AI changed the title [WIP] Support setting an array from C++ container Add CopyFrom methods to GenericArrayView for C++ container support Dec 6, 2025
Copilot AI requested a review from AaronWebster December 6, 2025 01:27
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.

Support Setting an Array from C++ Container

2 participants