Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 32,687 of 33,346    |
|    =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All    |
|    Re: Singletons    |
|    24 Nov 12 15:58:53    |
   
   From: daniel.kruegler@googlemail.com   
      
   Am 24.11.2012 19:52, schrieb Balog Pal:   
   > On 11/22/2012 6:26 AM, Daniel Krügler wrote:   
   >> I also don't see how you can compile-time enforce the   
   >> essential invariant of a singleton - namely that only one object of   
   >> type X exists.   
   >   
   > Err, what makes that an attribute of a singleton? And what possible   
   > benefits could that create?   
   >   
   > Signeton is an *object* that is accessible from anywhere in the   
   > application, and *that* instance is surely the same.   
      
   This is certainly also some design pattern, but it is not the classic   
   singleton pattern. The classic source ("Design Pattern" from the Gang of   
   Four) defines the intent as   
      
   "Ensure a class only has one instance, and provide a global point to   
   access it"   
      
   Similarly the definition found here   
      
   http://en.wikipedia.org/wiki/Singleton_pattern   
      
   starts with   
      
   "the singleton pattern is a design pattern that restricts the   
   instantiation of a class to one object"   
      
   > Like std::cout, cerr are proper singletons. But they share a class, and   
   > you can have any number of other ostreams.   
      
   You may describe them as singletons but they are not so by the classic   
   design pattern definition.   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca