C++ (Qt)template <class T>struct MyTemplateClass { T * Get( size_t ); void Set( T *, size_t ); void Read( MyStream & ); void Write( MyStream & ) const;};
C++ (Qt)template< class T >struct Serializer {}; template< class T >struct Serializer< MyTemplateClass< T > >{ static bool read ( MyStream &, MyTemplateClass< T > & ); static bool write ( MyStream &, const MyTemplateClass< T > & );}; struct Serializer< int >{ static bool read ( MyStream &, int & ); static bool write ( MyStream &, int );};
C++ (Qt)template < class T >MyStream & operator << ( MyStream & stream, const T & value ){ Serializer< T >::write( stream, value ); return stream;} template < class T >MyStream & operator >> ( MyStream & stream, T & value ){ Serializer< T >::read( stream, value ); return stream;}
C++ (Qt)template <class T>struct MyTemplateClass { T * Get( size_t ); void Set( T *, size_t ); template <class Stream> void Read( Stream & ); template <class Stream> void Write( Stream & ) const;};
C++ (Qt)ObjA objA;ObjB objB;ObjC objC;ObjD objD; stream out;objA.write(out);out << objB;objC.Write(out);objD.write2Stream(out);
C++ (Qt)ObjA objA;ObjB objB;ObjC objC;ObjD objD; stream out; out << objA << objB << objC << objD;
C++ (Qt)...stream out;objA.write(out);out << objB;objC.Write(out);objD.write2Stream(out);
C++ (Qt)std::vector<Object1> arr1;std::vector<Object2> arr2;
C++ (Qt) template <class Stream> void Read( Stream & );
C++ (Qt)template <class>struct serializer {}; template <>struct serializer<XMLStream>{ template <class T> static bool read(XMLStream & in, T & data) {} template <class T> static bool write(XMLStream & out, const T & data) {}} template <class Stream> void Read( Stream & in) { serializer<Stream>::read(in, *this); }
C++ (Qt)template <class T>class SomeClass{public: template <class Stream, class R> friend Stream & operator<<(Stream &, const SomeClass<R> &); template <class Stream, class R> friend Stream & operator>>(Stream &, SomeClass<R> &); private: T data;}; template <class Stream, class R>Stream & operator<<(Stream & out, const SomeClass<R> & obj){ out << obj.data; return out;} template <class Stream, class R>Stream & operator>>(Stream & in, SomeClass<R> & obj){ in >> obj.data; return in;} int main(){ SomeClass<int> obj; std::cin >> obj; std::cout << obj; return 0;}
C++ (Qt)QVector<SomeClass> vector; out << vector;
C++ (Qt)out << obj;in >> obj;