List Info

Thread: operator<< problems




operator<< problems
country flaguser name
Poland
2007-03-09 16:06:34
Hello,

I have written a simple hello.cpp - [1], which doesn't
compile - [2]. After 
some "investigation" I have tracked down the
problem to boost/python/str.hpp 
header. Removing str.hpp and numeric.hpp, which includes it,
from python.hpp 
make the hello.cpp compile and work just fine:
>>> import hello
>>> blah = hello.World()
>>> blah.set("foo")
>>> print blah
foo

System info: 
boost=1.33.1, gcc-4.1.2, glibc-2.5, kernel 2.6.20-gentoo
x86_64, python-2.4.4

[1] = http://dev.gentooexperimental.org/~peper/boost/hello.cpp

[2] - http://dev.gentooexperimental.org/~peper/boost/hello.e
rror

-- 
Best Regards,
Piotr Jaroszynski
_______________________________________________
C++-sig mailing list
C++-sigpython.org
http:
//mail.python.org/mailman/listinfo/c++-sig

Re: operator<< problems
user name
2007-03-10 04:33:09
On 3/10/07, Piotr Jaroszynski <p.jaroszynskigmail.com> wrote:
> Hello,
>
> I have written a simple hello.cpp - [1], which doesn't
compile - [2]. After
> some "investigation" I have tracked down the
problem to boost/python/str.hpp
> header. Removing str.hpp and numeric.hpp, which
includes it, from python.hpp
> make the hello.cpp compile and work just fine:
> >>> import hello
> >>> blah = hello.World()
> >>> blah.set("foo")
> >>> print blah
> foo
>
> System info:
> boost=1.33.1, gcc-4.1.2, glibc-2.5, kernel
2.6.20-gentoo x86_64, python-2.4.4
>
> [1] = http://dev.gentooexperimental.org/~peper/boost/hello.cpp

> [2] - http://dev.gentooexperimental.org/~peper/boost/hello.e
rror


This is a known problem/bug. The work around is pretty
simple: use
boost::python::self_ns::str instead of boost::python::str.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-
binding.net/
_______________________________________________
C++-sig mailing list
C++-sigpython.org
http:
//mail.python.org/mailman/listinfo/c++-sig

Re: operator<< problems
country flaguser name
Poland
2007-03-10 05:29:57
> This is a known problem/bug. The work around is pretty
simple: use
> boost::python::self_ns::str instead of
boost::python::str.
If only I had known this earlier  Many
thanks!

Btw. How would you bind copy constructor? To __copy__? If so
please advise 
how. I tried:
class_<VersionSpec_wrapper>("VersionSpec",
init<const std::string &>())
        .def(init<const VersionSpec &>())

but then the string constructor doesn't work:
TypeError: No registered converter was able to extract a C++
reference to type 
std::string from this Python object of type str

-- 
Best Regards,
Piotr Jaroszynski
_______________________________________________
C++-sig mailing list
C++-sigpython.org
http:
//mail.python.org/mailman/listinfo/c++-sig

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )