How to override a property setter?
Dec. 18, 2014
11:21 a.m.
I got a class: class X { private: std::wstring text_; public: std::wstring text() const { return text_; } void set_text(const std::string& text) { text_ = from_utf8(text); } void set_text(const std::wstring& text) { text_ = text; } }; I'm trying to use it as a property: BOOST_PYTHON_MODULE(test) { class_<X>("X") .add_property("text", &X::text, <what here?>) ; } What should I write to get following behavior:
x = X() x.text = "abc" # I want X::set_text(const std::string&) to be invoked here x.text = u"abc" # Here I expect X::set_text(const std::wstring&) to be called
-- Ilya.
4131
Age (days ago)
4131
Last active (days ago)
0 comments
1 participants
participants (1)
-
ilias