Odd desire. Platform to what we compile is known compile time so
making it run-time dynamic feels absurd waste.
> The derived class files contain definitions of operator>> to read some
> config data in - but not for the class itself, but for one of the member
> data types.
Sometimes dynamic polymorphism is used only to improve
testability. Through polymorphic interface it is easy to inject
dummies, fakes, simulators and mocks for testing. Virtual calls
are fine anywhere but in rare most performance-critical
places.
But that does not mean that all such alternatives may be really
compiled into whole product. That is error if done.
Also the interface of dynamic polymorphism being more elegant
does not mean that static polymorphism should not be used.
> That's OK, except that under the hood the way this is called is to use
> lexical_cast (not Boost's, but something similar) to convert a config
> line into the data type. And internally that calls the operator>> that
> is in scope at the time the lexical_cast function was called.
>
> It wasn't obvious that this is what was going wrong until I put trace in
> place, and ran it on one of the platforms that was hitting the problem.
> The serialisation failed, and it then used default data rather than
> complaining.
Yes added (unneeded) complexity and tricks can always result with
added chances of bugs and other confusion. What is decided compile
time can be also diagnosed compile time. Compile time diagnosed
issues are cheapest to fix. Compiling for all supported platforms
takes time but for that there is continuous integration.