Bah

Actually, that code below turns out to be less useful than I’d hoped, as the singleton constraint is only enforced through the getInstance() member function and not through the constructor. I’m sure there must be a way of getting round it, but I can’t work out what it is; the central issue is that the base class is constructing the derived class through a template parameter. Setting the base class constructor to private means that the derived class cannot be constructed at all; setting it to protected means that the derived class can be constructed by normal means as well as the getInstance() member. Setting the derived class constructor to either private or protected means that the base class cannot access it, as so far as SingletonPolicy is concerned, it’s a separate class.

I think there’s some icky solution workable by deriving from both classes, but I’ll have to go away and think about it a bit.

Comments are closed.