it is possible in C++ to execute the C++ code from string variable. Like in Javascript:
var theInstructions = \"alert(\'Hello World\'); var x = 100\"; var F
You can use Cling as C++ interpreter.
I created small CMake project for easier Cling integration: C++ as compile-time scripting language (https://github.com/derofim/cling-cmake)