Separate one-time code paths

I am implementing an application with different code codes, which should be selected once at startup, and then fixed forever for this execution, for example, by choosing the rendering path D3D11 or D3D9.

Obviously, I don't want to duplicate all my other code.

Is runtime inheritance (without virtual inheritance) a fair solution? I don't want to waste a ton of performance creating a virtual search when the type has been fixed long ago. Not only that, but it makes me nervous that functions cannot be inlined and regardless of whether it affects RVO and NRVO, etc. Am I just worried about this?

+4
source share
2 answers

I decided that since the number of paths is minimal, I would compile them as a DLL and load, for example. D3D9Main (), which will be compensated using a preprocessor to select types at compile time. Much simpler than using templates and much faster / easier than using inheritance.

+2
source

You can use the common components described in "Modern C ++ Design" , but I'm not sure if this is what you are looking for.

0
source

Source: https://habr.com/ru/post/1333289/


All Articles