|
Re: def( str( self)) error: msg#00250python.c++
On Mon, 2003-05-26 at 16:08, David Abrahams wrote: > From: David Abrahams <> > Date: Mon, 26 May 2003 16:01:16 -0400 > Subject: [C++-sig] Re: def( str( self)) error > Reply-To: c++-sig@xxxxxxxxxx > > I'm using G++ 3.2.2, with identical errors on Win32/MinGW and Debian > > Sid. > > Well, you're not allowed to add definitions to std:: - your function > should go in namespace physics. I'm not sure that would make a > difference though; it seems it should be found by Koenig Lookup > either way. Done. > Bug reporting and help requests 101: Why don't you post a small > reproducible example, and at least give the full text of the error > message? Very well, here it is: ------ testme.cpp -------- #include <istream> #include <ostream> #include <boost/python.hpp> namespace physics { class vector { public: double x, y, z; }; template<typename char_T, class traits> std::basic_ostream<char_T,traits>& operator<<( std::basic_ostream<char_T,traits>& stream, const vector& v) { std::basic_ostringstream<char_T,traits> s; s.copyfmt( stream); s.width( 0); s << "<" << v.x << "," << v.y << "," << v.z << ">"; stream << s.str(); return stream; } template< typename char_T, class traits> std::basic_istream< char_T,traits>& operator>>( std::basic_istream<char_T,traits>& stream, const vector& v) { double x, y, z; char_T ch; stream >> ch; if (ch == '<') { stream >> x >> ch; if (ch == ',') { stream >> y >> ch; if (ch == ',') { stream >> z >> ch; v = vector( x, y, z); } else if (ch == '>') { v = vector( x, y); } else { stream.setstate( std::ios::failbit); } } else { stream.setstate( std::ios::failbit); } } else { stream.setstate( std::ios::failbit); } return stream; } } // !namespace physics using namespace boost::python; BOOST_PYTHON_MODULE(libphysics) { class_< physics::vector>( "vector") .def( str( self)) ; } compiled with: $ g++-3.2 -c -o testme.lo -fpic -I/usr/include/python2.2 testme.cpp testme.cpp: In function `void init_module_libphysics()': testme.cpp:67: no matching function for call to ` boost::python::class_<physics::vector, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified> ::def(boost::python::str)' |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: exception specifiers and pyste: 00250, Nicodemus |
|---|---|
| Next by Date: | Re: def( str( self)) error: 00250, Jonathan Brandmeyer |
| Previous by Thread: | Re: def( str( self)) errori: 00250, David Abrahams |
| Next by Thread: | Re: def( str( self)) error: 00250, Jonathan Brandmeyer |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |