[C++-sig] static methods, and -ftemplate-depth observations

Hugo van der Merwe hugo at adept.co.za
Mon Jul 1 22:46:03 CEST 2002


Observation:

When I wrap an 11 parameter constructor, I have to set
-ftemplate-depth-35 - 34 is too small. If I remove the 11 parameter
constructor, I can get away with 23 ...

I get heaps of error messages if I have it too small. The first being
(for the case of 20, without the 11 parameter constructor):

/home/hugo/Programming/boost/boost/mpl/list/traits.hpp:43: template instantiation depth exceeds maximum of 20
/home/hugo/Programming/boost/boost/mpl/list/traits.hpp:43:  (use -ftemplate-depth-NN to increase the maximum)

This is g++ 2.95.4, David mentioned it's unsupported. With g++ 3.0.4, 35
is also too small, I have to push it up to 36.

I'm leaving the 17 parameter constructor until I get round to dealing
with const float* and const Uint8* (I think this is trivial, it was in
V1?), I don't need this beast in a rush. (I'll also deal with my arity
issues then, if there indeed *are* issues. Must still investigate
thoroughly.)

What I'm trying to deal with next, is wrapping "static Settings*
GetInstance" returning the single, always existing, global instance of
the Settings class for the library. The way I interpreted the examples
and docs (which isn't too good, I haven't got a proper understanding of
all the Call Policy things yet), I did:

    boost::python::module foo("foo");
    foo
	.add(
	    boost::python::class_<Settings>("Settings")
	    .def("GetInstance", &Settings::GetInstance,
		 return_value_policy<reference_existing_object>())
        );

Is that the right policy? As the instance always exists, I want Python
to use the pointer directly.

This doesn't give me a proper "static method" though, it's still
expecting a "self" parameter too. Wrapping this in V1 was trivial, it
seemed to do the right thing. I expect it just left out the "self"
parameter? This is how I did "static methods" in 2.1.

I did notice Python 2.2 has "proper" static methods. (What's the
significance, just that you can then also call these on instances of the
class, whereas with the "old" approach you have to specifically call it
on the class itself?)

So does V2 do static methods yet?

Thanks,
Hugo van der Merwe

(docstrings some time in the future... ?)





More information about the Cplusplus-sig mailing list