Phoenix is utility for lazy functors.
You need none here (there is nary an expression template in sight).
So, you can make your own factory method template:
template <typename PathType> IPath* make_path(CPathModel const& model) {
return new PathType(model);
}
And use it:
static FactoryMap factory_map = map_list_of<std::string, PathFactoryFunction>
("plu", &make_path<CPluPath>)
("time_of_day", &make_path<CTimeOfDayPath>)
("probability", &make_path<CProbabilityPath>)
;
Job done.
Although, at this point, there is zero benefit to using the map to lookup the factory. In fact, it's only wasteful. A simple switch[1] would be far superior. More so, because it removes the type erasure (implicit virtual polymorphism) in std::function
.
[1] In fact, it would need to be chained if
s, or you can switch on a Perfect Hash