We just upgraded from a quite old VC++ to 2005. In the process, something
has stopped working that seems like it's completely legal. Basically we have
our own very large framework. We have the usual streaming classes (base
classes for in and out streams, from which various specific streaming
classes are derived for files, memory, etc...) and the usual
templatized collection classes. We want our collections to be streamable,
where the instantiation element supports it, so we provide the usual global
(friend) streaming operators with each collection type, so that
streamability isn't forced on the instantiation element types, something
like:
//
// A templatized collection class with friend declarations for
// the streaming operators
//
template <class T> class TFundStack : public TObject
{
public :
.......
protected :
friend TBinOutStream& operator<<
(
TBinOutStream& strmOut
, const TFundStack<T>& fcolToStream
);
friend TBinInStream& operator>>
(
TBinInStream& strmIn
, TFundStack<T>& fcolToStream
);
}
// In the same header, global streaming operators
template <class T> TBinInStream&
operator>>(TBinInStream& strmToReadFrom, TFundStack<T>& colToStream)
{
}
template <class T> TBinOutStream&
operator<<(TBinOutStream& strmToWriteTo, const TFundStack<T>& colToStream)
{
}
* TBinInStream and TBinOutStream are the base classes from which various
types of binary in/out streams are derived.
// In a test app, I'd create a stack, put something in it
TFundStack<tCIDLib::TCard4> fcolStack(4);
fcolStack.Push(1);
// Then create an memory based output stream and stream the stack
TBinMBufOutStream strmTestOut(8192, 8192);
strmTest << fcolStack << kCIDLib::FlushIt;
The compiler doesn't find the global operators and I get an unresolved
symbol error on operator<<(TBinOutStream&, TFundStack<tCIDLib::TCard4>), so
it's not making the connection from the streaming of the stack to the
provided global streaming operator.
Is there something I'm missing here? Is this no longer valid in C++ or is
this some quirk of VC++ 2005, or is there some new switch I need or some
such thing?
-------------------------------------
Dean Roddey
Chairman/CTO, Charmed Quark Systems
www.charmedquark.com