Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer::set_final_data accepts weak_ptr<T>, not <T[]> #1011

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fknorr
Copy link
Contributor

@fknorr fknorr commented Dec 17, 2024

See [4.7.2.1]:

The finalData points to where the outcome of all the buffer processing is going to be copied to at destruction time, if the buffer was involved with a write accessor.

Destination can be either an output iterator or a std::weak_ptr<T>.

Note that a raw pointer is a special case of output iterator and thus defines the host memory to which the result is to be copied.

Not sure if this was different in an earlier spec revision.

@TApplencourt
Copy link
Contributor

Agree.

For example, for buffer in we have a special overload for T[]. buffer(const std::shared_ptr<T[]>& . We don't have such for final_data as you noticed.

@tomdeakin
Copy link
Contributor

One more reviewer please (total 2 for this please)

Copy link
Member

@keryell keryell left a comment

Choose a reason for hiding this comment

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

I wonder whether this should be a specification fix to accept smart pointers on T[] also.

@@ -63,21 +63,19 @@ class buffer_storage_test {

// Case 3 - Weak pointer
std::shared_ptr<T[]> data_shared_ptr(new T[size]);
std::weak_ptr<T[]> data_final3 = data_shared_ptr;
std::shared_ptr<T> data_shared_ptr_alias(data_shared_ptr,
Copy link
Member

Choose a reason for hiding this comment

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

Why doing this, since you initialize it also with the pointer from the shared pointer handling the ownership? 🤔
OK, after more thoughts you do this to have the same shared pointer but returning a pointer of the array decay.
You could add a comment. 😄

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.

4 participants