Hey Gabe, Could you describe in a little more detail why you want to templatize a SimObject. Since python doesn't have support for templates, I don't really like the idea of supporting this.
One option is to have the Python side of the SimObject be the "specialization" and then you'd just have to implement the SimObjectParams::create() function to return the specialized template for each of the types you want to support from Python. Does that make sense? Maybe this is what you meant by "subclassing" For instance: *my_simobject.hh:* template <type T> MySimObject public SimObject { ... }; *my_simobject.cc:* MySimObjectIntParams::create() { return MySimObject<int>(this); } MySimObjectFloatParams::create() { return MySimObject<float>(this); } *MySimObject.py:* class MySimObjectGeneric(SimObject): # I'm not sure if this is exactly right... ... <all of the params> class MySimObjectInt(MySimObjectGeneric): <header file, etc.> class MySimObjectFloat(MySimObjectGeneric): <header file, etc.> I would say that if the above doesn't work now, we should update things so it does work. However, I don't think we should do any of this *automatically* for templated SimObjects. Cheers, Jason On Fri, Feb 15, 2019 at 5:55 PM Gabe Black <gabebl...@google.com> wrote: > Hi folks. I'm trying to create a SimObject out of a templated class (the > python Param type uses a specialization of it), and the pybind11 generated > code doesn't compile because the predeclaration of the class type isn't > syntactically correct since it's a template. I can work around this problem > by, for instance, subclassing it and then using that subclass (at least I > think I can, I haven't tried it yet), but it would be nice if the system > could handle it. > > It's not obvious how to fix it since it's not obvious from the fully > specified type how it should be prototyped, so it's not a quick fix. Has > anyone attempted to get this to work, and/or have a solution? > > Thanks! > Gabe > _______________________________________________ > gem5-dev mailing list > gem5-dev@gem5.org > http://m5sim.org/mailman/listinfo/gem5-dev _______________________________________________ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev