Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to keep static polymorphic objects in vector?
How to keep static polymorphic objects in vector? [message #1843467] Sat, 31 July 2021 06:24 Go to next message
kate necon is currently offline kate neconFriend
Messages: 2
Registered: January 2021
Junior Member
Hello everyone!

I designed my program using of Curiously recurring template pattern. I have BaseComponent<T> class and about 100 classes that are deriving from it. I want to init objects of these classes in runtime and store these objects in a vector in a specific order. Then go through this vector and call the BaseComponent<T> interface for each of them. Since I can't have vector<BaseComponent*> I added Component class. So the hierarchy is following: Component -> BaseComponent<T> -> other classes. It allows me to keep objects in specific order with vector<Component*>. But then these objects can't be cast to BaseComponent and don't have interface I required. I can use virtual function but it kills the whole idea of CRTP (and performance too). I did measurements and in my case, the use of virtual functions is super bad.

In brief: I want to have BaseComponent<T> in a specific order and use that interface without virtual functions. Does someone have advice on how can I achieve that?showbox speed test

[Updated on: Tue, 03 August 2021 13:15]

Report message to a moderator

Re: How to keep static polymorphic objects in vector? [message #1843504 is a reply to message #1843467] Tue, 03 August 2021 06:52 Go to previous message
David VavraFriend
Messages: 1430
Registered: October 2012
Senior Member
This is off-topic for the forum which is about issues arising from using Eclipse/CDT.
The are other forums for dealing with programming such as
Previous Topic:Debugger buttons grayed out
Next Topic:breakpoints not working from IDE
Goto Forum:

Current Time: Sun Jul 03 03:19:49 GMT 2022

Powered by FUDForum. Page generated in 0.01557 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top