$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Jason Hise (chaos_at_[hidden])
Date: 2005-01-08 21:20:55
I thought of a solution to access the derived class's ctor which by all 
means should work, however I'm probably missing something obvious in 
this test version of my idea. Why does my compiler say that 
SingletonAllocationHelper < D > doesn't have access to D's ctor?
template < typename T >
class Singleton
{
public:
    static void foo (  )
    {
        Create ( ( T * ) 0 );
    }
protected:
    Singleton (  )
    {
    }
private:
    static void Create ( T * p )
    {
        SingletonAllocationHelper < T > :: Create ( p );
    }
};
template < typename T >
class SingletonAllocationHelper : public T
{
private:
    friend class Singleton < T >;
    SingletonAllocationHelper (  );
    SingletonAllocationHelper ( const SingletonAllocationHelper & );
    ~ SingletonAllocationHelper (  );
    static void Create ( T * p )
    {
        new ( p ) T (  );
    }
};
class D : public Singleton < D >
{
protected:
    D (  )
    {
    }
};
int main (  )
{
    D :: foo (  );
}
-Jason