[C++-sig] Question about passing ordinary pointers (like int*) to functions
David Abrahams
dave at boost-consulting.com
Fri Oct 20 03:54:25 CEST 2006
"Shandong Han" <shandong.han at mizuho-sc.com> writes:
> Sorry if this is too naive, but I searched the internet and digged out the
> previous mails here without any luck...
>
> I am new to this, and my question is pretty simple: how to call functions
> which use a pointer to return value? Sample code is as follows:
>
> ===================================
>
> #include "boost/python.hpp"
> #include "boost/python/suite/indexing/vector_indexing_suite.hpp"
>
> namespace bp = boost::python;
>
> int add(int a, int b, int* s)
> {
> *s = a + b;
> return 0;
> }
Just put a thin wrapper around the function:
boost::python::tuple add(int a, int b)
{
return boost::python::make_tuple(0, a+b);
}
Then wrap that
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list