home bbs files messages ]

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,759 of 33,346   
   Ian Collins to Dave Abrahams   
   Re: Singletons   
   20 Dec 12 21:45:38   
   
   From: ian-news@this.is.invalid   
      
   Dave Abrahams wrote:   
   > on Tue Dec 18 2012, Ian Collins  wrote:   
   >   
   >> I would certainly dispute the impact of singletons on testability.   
   >   
   > You would?   
   >   
   >> Anyway, I encountered another real life use case where DI can't be   
   >> used today: functions called from an external library.  I have a   
   >> set of functions called from an RPC library that use a singleton   
   >> connection to access another process.  The calling library has no   
   >> knowledge of this connection, so it can't be passed.  I expect this   
   >> situation isn't uncommon.   
   >   
   > If the calling library doesn't let you pass data through to these   
   > functions, you can still templatize the functions and get access to   
   > the "singleton" through the template parameter.   
      
   Not in this case, the caller in this example gets the function's   
   address from a UNIX dlsym call, so the functions have to be extern "C"   
   which rules out function templates.  Now I could add another level of   
   indirection..   
      
   --   
   Ian Collins   
      
      
         [ 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