### Creating a Streamable Template Class

Streamable template classes differ from ordinary non-templatized classes in their use of the streamable definitions and declarations macros. The macros used for ordinary classes will not expand correctly within template classes. They are replaced by a combination of inline code and an alternate declarations macro, as shown in the following example:

    template <class AType>
    class IMyClass : public IMSTREAMABLE {
        static IStreamableHelperFor< IMyClass<AType> > fgStreamableHelper;
        StreamableTemplateDeclarationsMacro;

    private:
        // ...
    };

Note: Each instantiation of a template class is really a new class type. When you instantiate a streamable template class, you must define and initialize its IStreamableHelperFor variable:

The following shows an instantiation of IMyClass over int in the program's implementation file:

    #include <myclass.hpp>

    extern IStreamModule gMyStreamModule;

    IMyClass<int> foo;
    IStreamableHelperFor< IMyClass<int> > IMyClass<int>::fgStreamableHelper(
        gMyStreamModule, 'IMyClass<int>');

The following shows another instantiation of the IMyClass, this time over IString:

    #include <myclass.hpp>

    extern IStreamModule gMyStreamModule;

    IMyClass<IString>    bar;
    IStreamableHelperFor<IMyClass<IString> > IMyClass<int>::fgStreamableHelper(
        gMyStreamModule, 'IMyClass<IString>');

Introduction to the Streaming Classes
Data Streams

Adding Streaming Support to Structs and Simple Classes
Creating a Streamable Class
Instantiating a Stream Module
Enabling Release-to-Release Data Compatibility
Streaming Base Classes
Instantiating a Data Stream