Login  Register

C++ help needed: singleton.hpp

Posted by Klaus Spanderen-2 on Sep 21, 2007; 8:24pm
URL: http://quantlib.414.s1.nabble.com/C-help-needed-singleton-hpp-tp9802.html

Hi

in ql/patterns/singleton.hpp

   68     template <class T>
   69     T& Singleton<T>::instance() {
   70         static std::map<Integer, boost::shared_ptr<T> > instances_;
   71         #if defined(QL_ENABLE_SESSIONS)
   72         Integer id = sessionId();
   73         #else
   74         Integer id = 0;
   75         #endif
   76         boost::shared_ptr<T>& instance = instances_[id];
   77         if (!instance)
   78             instance = boost::shared_ptr<T>(new T);
   79         return *instance;
   80     }

IMO this function should be declared as inline function to avoid linker
problem.

 69     inline T& Singleton<T>::instance() {

Background: I'd problems with this function when linking QL under Windows to a
project without including the QL project into my project (simply linked
static QL library).

any comment?

cheers
--
Klaus Spanderen
Ludwig Erhard Str. 12
48734 Reken (Germany)
E-Mail: [hidden email] (remove NOSPAM from the address)


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev