Classdesc 3.44
Poly< T, Base > Struct Template Reference

#include <polyBase.h>

Inheritance diagram for Poly< T, Base >:
Inheritance graph
Collaboration diagram for Poly< T, Base >:
Collaboration graph

Public Member Functions

Polyclone () const
 clone has to return a Poly* to satisfy covariance

Detailed Description

template<class T, class Base>
struct classdesc::Poly< T, Base >

utility class for building the derived types in a polymorphic heirarchy. Base is the base of the heirarchy.

 A possible use is as follows:

 class MyBase: public PolyBase<int>
 {
    static MyBase* create(int); // factory method
 };

 template <int t>
 class MyClass: public Poly<MyClass, MyBase>
 {
    public:
      int type() const {return t;}
 };

see also Factory class for another way of doing this static MyBase* MyBase::create(int t) { switch (t) { case 0: return new MyClass<0>; case 1: return new MyClass<1>; case 2: return new MyClass<2>; default: throw std::runtime_error("unknown class construction requested"); } }

See also descriptor specific poly classes, such as polypack.h


The documentation for this struct was generated from the following file: