dsign
dsign

Reputation: 12700

Cython C++ and std::string

What is the best way of using C++ standard std::string from cython? The last cython distribution should make it easy anyway, but I wonder why there are wrappers for std::vector and not for std::string...

Upvotes: 18

Views: 9453

Answers (2)

Jim Garrison
Jim Garrison

Reputation: 4276

Cython 0.16 includes wrappers for std::string, which can be imported with:

from libcpp.string cimport string

Upvotes: 23

dsign
dsign

Reputation: 12700

Oops, this question has been hanging here for a few days now. At the end I did this:

cdef extern from "string" namespace "std":
    cdef cppclass string:
        char* c_str()

which is not a complete solution but still it does the thing.

Upvotes: 8

Related Questions