I wrote the following traits that defines some policy classes:
namespace memory
{
struct on_RAM
{
template<typename T>
using pop_sizes_type = PopulationSizeOnRAMImplementation<T>;
template<typename T>
using flow_type = FlowOnRAMImplementation<T>;
};
struct on_disk
{
template<typename T>
using pop_sizes_type = PopulationSizeOnDiskImplementation<T>;
template<typename T>
using flow_type = FlowOnDiskImplementation<T>;
};
} // end namespace memory
I use these traits to configure the behavior of a simulation class: MyClass<memory::on_RAM>
or MyClass<memory::on_disk>
Eveything works fine, but I would like users of the resulting programs to be able to pick on or the other alternative without having to modify the source code.
I guess I can ask them to overwrite a default implementation by giving an option to CMake, that could give that to the compiler, that could make some compile-time choice. But I have no idea how to technically implement that. Any suggestion?