ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
Re: [C++-sig] Extracting C++ objects: documentation example fails.
by Joel Gerard other posts by this author
Oct 24 2003 2:35PM messages near this date
[C++-sig] Extracting C++ objects: documentation example fails. | [C++-sig] Re: Pickling object from nested class
Nevermind. I've seen the answer in a different post.

http://mail.python.org/pipermail/c++-sig/2003-September/005510.html

I think the documentation could benefit from this piece of information though.  It seems unu
sual
to me that ANSI C++ leaves the () off. Really?  It seems more logical that they appear.

Joel

--- Joel Gerard <llywelyn.geo@[...].com>  wrote:
>  Hi there,
>  
>  I'm trying to extract some wrapped objects from a python script in C++.
>  I've tried running the example from the docs to see how extract works, but
>  it wont compile:
>  
>  struct X
>  {
>     X(int x) : v(x) {}
>     int value() { return v; }
>   private:
>     int v;
>  };
>  
>  foo()
>  {
>      object x_class(
>         class_<X>("X", init<int>())
>            .def("value", &X::value))
>            ;
>  
>      // Instantiate an X object through the Python interface.
>      // Its lifetime is now managed by x_obj.
>      object x_obj = x_class(3);
>  
>      // Get a reference to the C++ object out of the Python object
>      X& x = extract<X&>(x_obj);
>      assert(x.value() == 3);
>  }
>  
>  I keep getting this error:
>  
>  d:\dev\samples\python\pythonlibtest\main.cpp(91): error C2440:
>  'initializing' : cannot convert from 'boost::python::extract<T>' to 'X &'
>          with
>          [
>              T=X &
>          ]
>  
>  
>  I'm using VC 7.  Is there something separate that I have to do to get this
>  example to compile?
>  
>  Thanks,
>  Joel
>  
>  
>  
>  
>  _______________________________________________
>  C++-sig mailing list
>  C++-sig@[...].org
>  http://mail.python.org/mailman/listinfo/c++-sig


=====


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
Thread:
Joel Gerard
Joel Gerard

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved