Background:
I am working on a C++ code-base with around 10 files each having 100+ lines of code. There is a data class that is fundamental to my project and is used in other classes/functions throughout my pipeline.
Initially, the class had 3-4 members based on types of information that I needed. Then I decided to use a map so that there is no limit on the types of information and more can be added easily (from the code itself, potentially based on input) if needed later. However, the map increased the run-time by atleast 3-4 times.
So temporarily I want to revert back to manually adding class members in the code. This will need 30-40 changes in the codebase from object.info["typeofinfo"]
as in a map (.info
is the map member here) to object.typeofinfo
as in manually defined class members. Doing this once is not a problem, but in the future I might want to try my luck at dynamic members (using the map) again.
Questions:
a) Is there a quick way to switch between these 2 versions at random points in the development of my project (which will only grow in size).
b) Is there a faster way (than map/unordered_map) to make the number of members in a class dynamic so that I can add more types of information into the class from within the code-base based on the input