No builtin support for std::string& in return values.

Bug #1286490 reported by Kevin Stenerson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyBindGen
Fix Committed
Low
Unassigned

Bug Description

There exists support for string references as parameters, but there is no built-in support for string references as return values.
Note, in this particular case I'm mostly concerned with a type like "const std::string&".

Just for reference, in case I'm doing something completely silly, here is the end of the error output received when using retval('const std::string &')

File "/usr/lib64/python2.7/site-packages/pybindgen/typehandlers/base.py", line 1437, in lookup
    raise TypeLookupError(tried_names)
pybindgen.typehandlers.base.TypeLookupError: ['std::string &']

Revision history for this message
Gustavo Carneiro (gjc) wrote :

This is because it is simply not possible to return a reference to a temporary variable, at least in "reverse wrappers". Adding support for returning references is really hard. I suggest you just use std::string instead of std::string& as type. It will probably work just as well as long as you are not using it in a virtual method or attribute.

Changed in pybindgen:
status: New → Confirmed
importance: Undecided → Low
Gustavo Carneiro (gjc)
Changed in pybindgen:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.