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

   By defining a [move 
constructor](https://en.cppreference.com/w/cpp/language/move_constructor) and 
[assignment 
operator](https://en.cppreference.com/w/cpp/language/move_assignment), like 
this:
   ```c++
   template <typename T>
   class TempVectorHolder {
     friend class TempVectorStack;
   
    public:
     ~TempVectorHolder() {
       if (stack_) {
         stack_->release(id_, num_elements_ * sizeof(T));
       }
     }
     TempVectorHolder& operator=(TempVectorHolder&& other) {
       stack_ = other.stack_;
       other.stack_ = NULLPTR;
       data_ = other.data_;
       other.data_ = NULLPTR;
       id_ = other.id_;
       num_elements_ = other.num_elements_;
       return *this;
     }
     TempVectorHolder(TempVectorHolder&& other) {
       *this = std::move(other);
     }
   
     T* mutable_data() { return reinterpret_cast<T*>(data_); }
   
    private:
     TempVectorStack* stack_ = NULLPTR;
     uint8_t* data_;
     int id_;
     uint32_t num_elements_;
   };
   ```
   


-- 
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