Quote:Original post by nobodynews
I'm reading through Modern C++ Design, by Alexandrescu and it does contain a lot of interesting information. Though he probably could have left out the singleton stuff.
Agreed. I'm reading through that chapter now. I'm glad to have read it, but I'm still not convinced that the singleton pattern is any more useful than I previously thought. Then again, the book is a few years old now, and most everyone was more accepting of the pattern back then.
The worse part, IMO is that he made the small-object allocator from chapter 4 a singleton, and I don't believe that it necessarily requires it or that its even a good idea. The downsides are *slightly* lessened by the fact that the template parameterization creates different small-object allocator singletons for different policies -- eg, a small-object allocator<SingleThreaded> is a different object than a small-object allocator<MultiThreaded> -- but this is still unnecessarily restrictive. For example, what if one wants to have multiple multi-threaded allocators assigned to independently-threaded portions of the application? You can get around this by having, for example, MultiThreadedAI and MultiThreadedGUI policies, but they're probably just duplicates with different names, which doesn't strike me as a better solution than the alternative of simply having the small-object allocator as an object, rather than a singleton.