$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-02-14 11:50:37
At 02:02 AM 2/14/2002, Matthias Troyer wrote:
 >
 >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.
 >>>
 >>> Matthias
 >>
 >> 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 )
 >>
 >> or:
 >>
 >> 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.
Yes, and because we've now seen Jen's approach, we are unlikely to be happy 
with something less elegant.
 >... My concern was that it seems in some cases I need
 >runtime-polymorphism using virtual functions.
Do you have a way to do that as an addition, rather than a replacement, for 
compile-time polymorphism?
--Beman