I am developing a code to simulate a Non-Volatile Memory (NVM). For that, I need several constants (memory dimensions, feature size, temperature etc.).
Until then, all my constants were defined at compile-time using pre-processor macros and constexpr variables. But as I needed to re-compile my code each time I wanted to modify the constants, I considered switching to run-time-defined variables.
I wanted to have two options to define the constants:
- Load the constants from a configuration file.
- Set them at the beginning of the execution manually (so that the code could be wrapped in another code).
I tried the proposal from these two questions:
- C++ Best practices for dealing with many constants, variables in scientific codes -https://scicomp.stackexchange.com/questions/2152/what-is-a-good-way-to-run-parameter-studies-in-c
- Setting global parameters: is this a reasonable use of const_cast and volatile?
Using a class to store the constants seems to be a good solution. However, it doesn't match exactly my requirements, as I would like to pass the constants/config file as a command line argument, facilitating code use in my opinion.
I also heard that boost library could do the work, but I heard that it has a quite expensive cost at compile and run time.
Do you think what I want to achieve is possible? Or am I taking the problem in the wrong way?