[C++-sig] Re: static const object access?
David Abrahams
dave at boost-consulting.com
Tue Jun 10 04:25:16 CEST 2003
Gavin Doughtie <gdoughtie at anim.dreamworks.com> writes:
> let's say I have a class:
>
> class A
> {
> // implementation of a special "Null" object
> };
>
> and another
>
> class B
> {
> private:
> static const A;
> public:
> static const A& getNullA() const {
^^^^^
Illegal; there's no "this" in a static member function
> return A;
> }
> };
>
> In python, I'd like B.getNullA() to always return the same python
> object, which in turn is initially populated by the C++ getNullA()
> call.
>
> I was trying to use "return_internal_reference" for the getNullA()
> method def
Did you read the reference docs for return_internal_reference? Which
Python argument object will the reference be internal to?
> but in python I get a "tuple index out of range" error.
>
> Enlightenment, anyone?
Well, there are no arguments!
// wrap this instead.
object getNullA()
{
static object nullA(ref(B::getNullA()));
return nullA;
}
HTH,
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list