Proper separation of CreateImpl() between interface and implementation
I find it pretty confusing that both, include/StochasticsInterface.h and include/Stochastics.h define their own static class functions CreateImpl();
:
static StochasticsInterface* CreateImpl(); // StochsticsInterface.h
static std::unique_ptr<StochasticsInterface> CreateImpl(); // Stochstics.h
When I try to link this library as shared library and use it like this (invoking the implementation),
#include <Stochatics/Stochastics.h>
void main()
{
std::unique_ptr<StochasticsInterface> my_stochastics { Stochastics::CreateImpl() };
}
I get an undefined reference to Stochastics::CreateImpl()
The only possible way to use it right now is:
#include <Stochatics/StochasticsInterface.h>
void main()
{
StochasticsInterface* my_stochastics { StochasticsInterface::CreateImpl() };
}
I see no point in using the interface to invoke an implementation, so I'd rather remove CreateImpl() method from the interface and leave it to the user how to invoke the implementation. In any way, properly implement the CreateImpl() method so that it can be resolved by the linker.