[C++-sig] Tutorial

Joel de Guzman djowel at gmx.co.uk
Tue Dec 24 21:54:22 CET 2002


Hi,

As for the const in std::string const name, Dave has fixed the code in the CVS, 
AFAIK. see http://mail.python.org/pipermail/c++-sig/2002-October/002284.html
As for the other mistake, it is my fault. Corrected in CVS. 

Regards,
--Joel

----- Original Message ----- 
From: "chuzo okuda" <okuda1 at llnl.gov>


> I read some of the tutorial. 
> 
> I cannot make it work without eliminating "const" in Class Data Members
> topic.
> How to make it work with const?
> 
> struct Var {
>    Var(std::string name) : name(name), value() {}
>    std::string const name;
>    float value;
> };
> 
> BOOST_PYTHON_MODULE_INIT(mytest3)
> {
>    using namespace boost::python; 
> 
>    class_<Var>("Var", init<std::string>())
>       .def_readonly("name", &Var::name)
>       .def_readwrite("value", &Var::value)
>       ;
> }
> 
> *** snips ***
> "boost::python::detail::copy_non_const_reference_expects_a_non_const_          
> reference_return_type<boost::add_reference<boost::add_const<boost::py          
> thon::objects::make_holder<1>::apply<boost::python::objects::detail::          
> select_value_holder<Var, Var>::type,
> *** snips ***
> 
> Also, on the next topic, Class Property, I see:
> 
>     class_<Num>("Num")
>              .add_property("rovalue", &Var::get)
>              .add_property("value", &Var::get, &Var::set);
> 
> It should be &Num::get and &Num::set.
> 
> Additionally, I would like to have a index page that can quickly find
> information such as "add_property", "def_readonly", etc.
> It would be very much helpful like python web page.
> Cheers!
> Chuzo
> 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
> 





More information about the Cplusplus-sig mailing list