Skip to content

Translate reference to array - #357

Merged
nunoplopes merged 4 commits into
Cpp2Rust:masterfrom
lucic71:array-reference
Sep 13, 2026
Merged

nunoplopes merged 4 commits into
Cpp2Rust:masterfrom
lucic71:array-reference

Conversation

@lucic71

@lucic71 lucic71 commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Reference to array is translated as Ptr<Box<[T]>> in refcount and *const/mut [T; N] in unsafe.

I added a new ConversionKind called Pointee to translate reference to array in refcount. The semantics are:

  • FullRefCount: Value<Pointee>
  • Pointee: the object itself
  • Unboxed: same as Pointee, except arrays which are [T; N] intead Box<[T]>

I also added Ptr::from_string_literal_array which is similar to Ptr::from_string_literal, the only difference is that that the new function returns Ptr<Box<[u8]>> instead of Ptr<u8>.

@nunoplopes
nunoplopes merged commit 1814bb5 into Cpp2Rust:master Sep 13, 2026
9 checks passed
joaotgouveia pushed a commit to joaotgouveia/cpp2rust that referenced this pull request Oct 27, 2026
Reference to array is translated as `Ptr<Box<[T]>>` in refcount and
`*const/mut [T; N]` in unsafe.

I added a new ConversionKind called Pointee to translate reference to
array in refcount. The semantics are:
* `FullRefCount`: `Value<Pointee>`
* `Pointee`: the object itself
* `Unboxed`: same as `Pointee`, except arrays which are `[T; N]` intead
`Box<[T]>`

I also added `Ptr::from_string_literal_array` which is similar to
`Ptr::from_string_literal`, the only difference is that that the new
function returns `Ptr<Box<[u8]>>` instead of `Ptr<u8>`.
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.

2 participants