[C++-sig] [boost.python] char arrays in structs

Markus Schöpflin markus.schoepflin at comsoft.de
Tue Jul 5 11:31:26 CEST 2005

Markus Schöpflin wrote:
> Ralf W. Grosse-Kunstleve wrote:
>>You don't have to use inheritance just to provide a wrapper. An unbound
>>function  will also work if the first argument is foo& or foo const& (and maybe
>>even foo* etc., I am not sure):
>>char const*
>>get_bar(foo& self) { return foo.bar(); }
>>  class<foo>("foo")
>>    .def("get_bar", get_bar)
>>  ;

I played with that a little and now I have:

template <class T, class R, R (T::*p)>
char const *get(T const &self)
   return self.*p;

   .add_property("bar", get<foo, char[4], &foo::bar>);

I wonder if there is a way to somehow get rid of specifying char[4] and 
probably foo manually.


More information about the Cplusplus-sig mailing list