pitrou commented on PR #40007:
URL: https://github.com/apache/arrow/pull/40007#issuecomment-1959691532

   You could either create a static constructor:
   ```c++
   template <typename T>
   class TempVectorHolder {
     friend class TempVectorStack;
   
    public:
     static Result<TempVectorHolder> Make(TempVectorStack* stack, uint32_t 
num_elements) {
       TempVectorHolder holder{stack, nullptr, 0, num_elements};
       ARROW_RETURN_NOT_OK(stack->alloc(num_elements * sizeof(T), 
&holder.data_, &holder.id_));
       return holder;
     }
   ```
   
   or, conversely, move the typed allocation API into TempVectorStack:
   ```c++
   class ARROW_EXPORT TempVectorStack {
     template <typename>
     friend class TempVectorHolder;
   
    public:
     template <typename T>
     Result<TempVectorHolder<T>> AllocateVector(uint32_t num_elements) {
       TempVectorHolder holder{this, nullptr, 0, num_elements};
       ARROW_RETURN_NOT_OK(alloc(num_elements * sizeof(T), &holder.data_, 
&holder.id_));
       return holder;
     }
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to