LoginSignup
0
0

More than 5 years have passed since last update.

Boost.Pythonで変更可能な文字列を扱ってTypeErrorになる話

Posted at

char* bufみたいなやつをboost::python::str(buf)すると

TypeError: No to_python (by-value) converter found for C++ type: char

って怒られる。strのコンストラクタ見たらstr(char const* s)って書いてある。だから

boost::python::str(const_cast<const char*>(buf))

が正解。なんでコンパイル時にエラーにならないのかと思ったらこんなのがあった。

template <class T>
explicit str(T const& other);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0