By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,399 Members | 1,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,399 IT Pros & Developers. It's quick & easy.

boost::python and automatic conversion for const std::string&

P: n/a
I have a lot of functions returning "const std::string&". Every time I
wrap one of those I have to do it like this:

class_.def("name", &someclass::bla,
boost::python::return_value_policy<boost::python:: copy_const_reference>()
);

Is there a way to register a return value conversion for "const
std::string&" so I can omit it every time I have to wrap functions
returning "const std::string&" ? I wan't those strings to be copied to
python as new strings (I don't want to hold a pointer to them).
Thanks

Dec 21 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 21 Dec 2006 07:30:41 -0800, ga****************@gmail.com
<ga****************@gmail.comwrote:
I have a lot of functions returning "const std::string&". Every time I
wrap one of those I have to do it like this:

class_.def("name", &someclass::bla,
boost::python::return_value_policy<boost::python:: copy_const_reference>()
);

Is there a way to register a return value conversion for "const
std::string&" so I can omit it every time I have to wrap functions
returning "const std::string&" ? I wan't those strings to be copied to
python as new strings (I don't want to hold a pointer to them).
I am not sure, you'd better ask this question o Boost.Python mailing list:
http://mail.python.org/mailman/listinfo/c++-sig/
Py++, Boost.Python code generator, does it for you: http://tinyurl.com/ygwdkz
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
Dec 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.