Re: Alternative to virtual template function
Lourens Veen ha scritto:
Alberto Ganesh Barbati wrote:
In the preliminary stages of the design, I agree that it might be
useful. However, the platform layer interface usually solidify quite
early during the life-cycle of a cross-platform project so I expect
the interface not to change very often. With your approach, each
time you change something in the implementation you need to
recompile the whole project, while my approach you just compile the
changed cpp file and relink.
The implementation of what? The platform layer, yes, indeed, but as
you said, it probably solidifies early and won't need much change
after that. Or am I misunderstanding you?
The interface of the platform layer solidifies early, as it's an
artifact shared by all platforms (which usually are maintained by
different people). However, the (possibly several) implementations of
such interface might change even in later stages, for example because of
bug fixes or optimizations. The problem with the templated approach is
that the whole implementation (and not just the interface) is included
by every compilation unit of the whole project.
The notorious "export" template feature is expected to help in this
scenario, but you must be lucky enough to have compilers that implement
export for all platforms you are working on. Given that AFAIK there is
only one compiler in the world that has it, chances are that you don't
want to follow this route. BTW, I don't even know how big is the actual
help provided by export feature...
In my particular case this isn't much of an additional problem since
just about everything is templated in the first place, and so it all
needs recompilation if I change the configuration. The 40 second
compilation time is manageable as well. I agree that for a larger
project this would be a problem. Something to consider when I design
my next research prototype at least.
40 seconds? Then either it's a very small project or you have a
super-computer at hand ;-) On a project of mine that I still consider of
relativly small size, complete rebuild took 20 minutes... So suppose you
have to debug that Nasty Bug(tm) that occurs only on one platform,
which, of course, is the one were you are least comfortable with. Now,
if every time you make a change you have to rebuild everything...
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]