[C++-sig] non-const arguments
Enrico Ng
enrico at fnal.gov
Thu Aug 8 16:27:24 CEST 2002
It is an int.
----- Original Message -----
From: "David Abrahams" <dave at boost-consulting.com>
To: "pysig" <c++-sig at python.org>
Sent: Tuesday, August 06, 2002 4:54 PM
Subject: Re: [C++-sig] non-const arguments
> What is the definition of Integer?
>
> if it's
>
> typedef X Integer;
>
> Where X is some builtin numeric type, well of course you can't publish
that
> interface in Python. All of the builtin numeric types are immutable.
>
> Decide on a Python interface that's consistent with Python's
immutability
> restrictions, and we can see how to wrap it.
>
> Perhaps
>
> tuple ran1(Integer x)
>
> would work better for you?
>
> -----------------------------------------------------------
> David Abrahams * Boost Consulting
> dave at boost-consulting.com * http://www.boost-consulting.com
>
>
> ----- Original Message -----
> From: "Enrico Ng" <enrico at fnal.gov>
> To: <c++-sig at python.org>
> Sent: Tuesday, August 06, 2002 5:41 PM
> Subject: [C++-sig] non-const arguments
>
>
> > I am new to boost and am attepting to use V2.
> >
> > I get the "TypeError: bad argument type for built-in operation"
error
> > message from python. It seems that since the variable "idum" is not
> > const and changes, python can't handle it.
> >
> > I have looked around your documentation and the
copy_non_cost_reference
> > class seems close to what I need but I am not sure.
> >
> > Here is some of the relavent code:
> >
> > class MathLib {
> > public:
> > static Real ran1(Integer &idum); <- idum is modified
> > };
> >
> > ==============================================
> >
> > #include <boost/python/class.hpp>
> > #include <boost/python/module.hpp>
> >
> > namespace python = boost::python;
> >
> > BOOST_PYTHON_MODULE_INIT(mathlib)
> > {
> > python::module("mathlib")
> > .def("ran1", &MathLib::ran1)
> > ;
> > }
> >
> >
> > _______________________________________________
> > C++-sig mailing list
> > C++-sig at python.org
> > http://mail.python.org/mailman/listinfo/c++-sig
>
>
>
> _______________________________________________
> 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