You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "felipecrv (via GitHub)" <gi...@apache.org> on 2023/09/26 20:05:13 UTC

[GitHub] [arrow] felipecrv opened a new issue, #37891: [C++] Pass shared_ptr by value to parametric type constructors

felipecrv opened a new issue, #37891:
URL: https://github.com/apache/arrow/issues/37891

   ### Describe the enhancement requested
   
   Types like `ListType` and factory functions like `list` take a `const std::shared_ptr<DataType>&` instead of a `std::shared_ptr<DataType>` that could be moved into the newly constructed `ListType` without the need of bumping a refcount and still support cases where caller can only give it a reference.
   
   Currently:
   
   ```cpp
   std::shared_ptr<DataType> list(const std::shared_ptr<DataType>& value_type) {
     return std::make_shared<ListType>(value_type);
   }
   ```
   
   After this issue is fixed:
   
   ```cpp
   std::shared_ptr<DataType> list(std::shared_ptr<DataType> value_type) {
     return std::make_shared<ListType>(std::move(value_type));
   }
   ```
   
   When working on this, we should take the time to go through every callsite and decide if a `std::move()` is possible without breaking correctness — things could break if the parameter is used after it's moved into the new instance of a parametric type.
   
   
   
   ### Component(s)
   
   C++


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org