[C++-sig] Re: wrapping constructor

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Thu Apr 8 18:13:09 CEST 2004


--- "Neal D. Becker" <ndbecker2 at verizon.net> wrote:
> template<typename CONT>
> inline X* MakeX (CONT v) {
>   return new X (v.begin(), v.end());
> }
> 
> template<typename CONT>
> inline void Compute_wrap (X& c, CONT v) {
>   c.Compute (v.begin(), v.end());
> }
> 
> BOOST_PYTHON_MODULE(Corr4_wrap) {
>   typedef std::vector<Complex>::const_iterator vc_cit;
> 
>   class_<X> ("X", no_init)
>     .def("__init__", boost::python::make_constructor(MakeX<const
> std::vector<Complex>& >))
>     .def("Compute", <what goes here?> )

      .def("Compute", Compute_wrap<std::vector<Complex> const&>)

>     ;
> 
> }

This will not work with older compilers such as gcc 2.96. If you need to
support non-conforming compilers use a cast or write non-template thin
wrappers, e.g. Compute_wrap_vector_complex.

Ralf


__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/




More information about the Cplusplus-sig mailing list