shwina commented on issue #34564:
URL: https://github.com/apache/arrow/issues/34564#issuecomment-1468855582

   Right, my understanding is that Cython doesn't really know about rvalue 
references or move semantics. To generate correct C++ code involving functions 
that accept rvalue references, you can declare them as accepting type `T`, and 
explicitly use `move()` when passing arguments to them.
   
   ```cython
   # distutils: language=c++                                                    
                                                                                
                          
   # extra_compile_args: -std=c++17                                             
                                                                                
                          
                                                                                
                                                                                
                          
   from libcpp.utility cimport move                                             
                                                                                
                          
                                                                                
                                                                                
                          
                                                                                
                                                                                
                          
   cdef extern from *:                                                          
                                                                                
                          
       """                                                                      
                                                                                
                          
       class Foo {                                                              
                                                                                
                          
         public:                                                                
                                                                                
                          
           Foo() = default;                                                     
                                                                                
                          
       };                                                                       
                                                                                
                          
                                                                                
                                                                                
                          
       void bar(Foo&& x) {                                                      
                                                                                
                          
           return;                                                              
                                                                                
                          
       }
       """                                                                      
                                                                                
                                                                                
                                                                                
                                            
       cppclass Foo:                                                            
                                                                                
                          
           Foo()                                                                
                                                                                
                          
                                                                                
                                                                                
                          
       void bar(Foo)  # no need to declare this void bar(Foo&&)                 
                                                                                
                                                              
                                                                                
                                                                                
                          
   cdef Foo f = Foo()                                                           
                                                                                
                          
                                                                                
                                                                                
                          
   # bar(f) -> compile error                                                    
                                                                                
                          bar(move(f))  # works
   ```


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