This week we’ve had a little C++-related chat with my colleague. One of our projects required an allocation of deeply nested std::vector. Something like this: std::vector<std::vector<std::vector<int>>>. My colleague asked if there’s a way to initialize the vector without the for loops.
Lately, I’ve been working on a GNSS-related project and taking my PhD exams and haven’t had any time to write any articles. I tried to make this project useful for my self-education as possible without compromising the quality of the software in general. There are several little tricks I’ve learned which I’ll wrap in articles for future use. Let me share one of those just to start writing again.
Today I’d like to share with you an approach I’ve been working on for some time now. It is called a configuration-driven polymorphism (CDP) and may be used to create a chain of function calls with different signatures during the run-time via reading some arbitrary configuration file.
TL;DR: using data = std::move(some_data) in the lambda capture may allow you to build some good abstractions for your code with no performance penalty.