Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:46

0001 // Copyright (C) 2001-2003
0002 // Mac Murrett
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See
0005 // accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // See http://www.boost.org for most recent version including documentation.
0009 
0010 #ifndef BOOST_SINGLETON_MJM012402_HPP
0011 #define BOOST_SINGLETON_MJM012402_HPP
0012 
0013 #include <boost/thread/detail/config.hpp>
0014 
0015 namespace boost {
0016 namespace detail {
0017 namespace thread {
0018 
0019 // class singleton has the same goal as all singletons: create one instance of
0020 // a class on demand, then dish it out as requested.
0021 
0022 template <class T>
0023 class singleton : private T
0024 {
0025 private:
0026     singleton();
0027     ~singleton();
0028 
0029 public:
0030     static T &instance();
0031 };
0032 
0033 
0034 template <class T>
0035 inline singleton<T>::singleton()
0036 {
0037     /* no-op */
0038 }
0039 
0040 template <class T>
0041 inline singleton<T>::~singleton()
0042 {
0043     /* no-op */
0044 }
0045 
0046 template <class T>
0047 /*static*/ T &singleton<T>::instance()
0048 {
0049     // function-local static to force this to work correctly at static
0050     // initialization time.
0051     static singleton<T> s_oT;
0052     return(s_oT);
0053 }
0054 
0055 } // namespace thread
0056 } // namespace detail
0057 } // namespace boost
0058 
0059 #endif // BOOST_SINGLETON_MJM012402_HPP