On Dec 20, 11:02 pm, Markus Dehmann <markus.dehm...@gmail.comwrote:
Quote:
Does anyone have a hint how to do the forward decl so that I don't
have to recompile every class that includes the Opts decl whenever I
add an option?
|
Someone may have a solution, but I would try to give the generic base
a clear responsibility - singleton instantiation of the applicable
derived. If options are applicable to the derived only, then it should
not be part of the singleton. I suppose the reason you want to make
it part of the singleton is because you need to instantiate each
derived with options. A couple of questions then come to mind.
- Is the type of the options unique per singleton/derived?
- If not unique, can the type of options vary.
- Can the value of options vary (is it default constructible or does
is only have static const members.
An idea might be to let the derived get its options from
a factory during its construction possible using typeid
or a string. I personally don't think it is idiomatic to
have arguments in instance. Otherwise you could possible
consider explicit creation of the singleton which
uses a non-instance method, the creation taking option
as argument.
In general the implementation of template code should be
stable as modification to it affects all translation units
that use it. If this is not the case, I think the unstable
code should be moved.
Hope this helps a little.
Regards,
Werner