On 02/11/2010 07:18 AM, Murray Cumming wrote:
On Fri, 2009-02-27 at 15:18 -0800, Alex Mohr wrote:
[snip]
If you have a PyObject *p and you want a bp::object,
construct it via:
object(handle<>(p)) // when p's a new reference
I find that I have to split the handle and object over two lines. If I
do this
boost::python::object cppobject(boost::python::handle<>(cObject));
and then something like this:
if(!cppobject.ptr())
doSomething()
then I get this weird compiler error on the if() line:
glom/python_embed/glom_python.cc:229: error: request for member ‘ptr’ in
‘cppobject’, which is of non-class type
‘boost::python::api::object(boost::python::handle<_object>)’
It's as if doing it on one line has changed the type.
It does !
In C++, if something may be interpreted as a declaration, it is a
declaration.
And in the above case, the first line may be interpreted as a
declaration of a function "cppobject" returning a bp::object, taking a
handle<>.
If you split things into three statements, by first instantiating a
(named) handle<>, then pass that to the cppobject constructor, the error
will go away, since that line then is no longer ambiguous.
HTH,
Stefan
--
...ich hab' noch einen Koffer in Berlin...
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig