Cython C++ static methods in a template class -


problem

i have template class in c++ has static method. looks more or less this:

template<typename t> class foo {     static std::shared_ptr<foo<t>> dosth(); } 

so in c++ call like: foo<int>::dosth();. in cython however, way call static methods using classname namespace:

cdef extern "bar.h" namespace "bar":     shared_ptr[bar] dosth()  # assuming shared_ptr declared 

but has no notion of templates. obviously, passing foo<t> namespace doesn't work, because translates foo<t>::dostr() in c++, no concrete type substituted t.

question

how in cython? there way, or workaround?

note: answer right @ time written (and still work) should use @robertwb's answer question instead properly.


i don't think can directly in cython. create thin wrapper of normal (non-static-method) c++ template function

template <typename t> std::shared_ptr<foo<t>> foo_t_dosth<t>() {    return foo<t>::dosth(); } 

and wrap method in cython

cdef extern "..."     shared_ptr[t] foo_t_dosth[t]() 

as aside, recommended way of wrapping static methods in cython looks (from https://groups.google.com/forum/#!topic/cython-users/xaeruq2yy0s)

cdef extern "...":    cdef foo_dosth "foo::dosth"()  # not declared memeber 

(by specifying actual function use string). doesn't here because doesn't cope templates. may have been me mis-advised on way trying...


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -