From: Matthias Troyer (troyer_at_[hidden])
Date: 2002-02-14 02:02:33
On Wednesday, February 13, 2002, at 06:19 PM, quendezus wrote:
>> No, I need at least three different types of streams at runtime.
>> That's why I think I need some type of polymorphism (templates or
>> virtual functions) on the stream.
> Ok, I think you are right: the person who calls the serialization
> function should be able to transmit some info to the serialization
> code (in your case, the stream to format the output). I realize this
> is necessary.
> Therefore the type of the stream (or the type of a context class)
> should be a template parameter :
> template < class T, class Context >
> void serialize( std::streambuf& dest, const T& t, Context& t )
> template < class T, class Stream >
> void serialize( Stream& dest, const T& t )
> I have already tried a solution like that and it seems to work but it
> is complicated. I will think about how to simplify it.
Jen's library already does this in a very elegant way using
templates. My concern was that it seems in some cases I need
runtime-polymorphism using virtual functions.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk