You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "shwina (via GitHub)" <gi...@apache.org> on 2023/03/14 21:15:16 UTC

[GitHub] [arrow] shwina commented on issue #34564: Building with Cython 3 shows warnings

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: github-unsubscribe@arrow.apache.org

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