Skip to content

Make pointer<T[]> trivially copyable - #9

Merged
tcbrindle merged 4 commits into
mainfrom
pr/trivially_copyable_array_ptr
Sep 4, 2026
Merged

Make pointer<T[]> trivially copyable#9
tcbrindle merged 4 commits into
mainfrom
pr/trivially_copyable_array_ptr

Conversation

@tcbrindle

Copy link
Copy Markdown
Owner

By giving slice<T> defaulted but private copy and assignment (rather than deleted as before) we can in turn default pointer<T[]> copy and assignment operators.

The result is that slice is still non-copyable and non-movable by external code (as we'd like) but now all specialisations of pointer are trivially copyable.

By giving `slice<T>` defaulted but private copy and assignment (rather than deleted as before) we can in turn default `pointer<T[]>` copy and assignment operators.

The result is that `slice` is still non-copyable and non-movable by external code (as we'd like) but now all specialisations of `pointer` are trivially copyable.
`checked_iterator` is three pointers in size, so it's probably better to take it by reference rather than by value in function arguments (if indeed an actual function call is ever generated for these comparison operators...)
We want to make triply sure that `operator==` returns the same thing as `operator<=>`, even though it always would do already in practise...
@tcbrindle
tcbrindle merged commit dae9f46 into main Sep 4, 2026
40 checks passed
@tcbrindle
tcbrindle deleted the pr/trivially_copyable_array_ptr branch September 11, 2026 14:40
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.

1 participant