Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/thread/detail/singleton.hpp @ 47

Last change on this file since 47 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.2 KB
Line 
1// Copyright (C) 2001-2003
2// Mac Murrett
3//
4// Distributed under the Boost Software License, Version 1.0. (See
5// accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7//
8// See http://www.boost.org for most recent version including documentation.
9
10#ifndef BOOST_SINGLETON_MJM012402_HPP
11#define BOOST_SINGLETON_MJM012402_HPP
12
13#include <boost/thread/detail/config.hpp>
14
15namespace boost {
16namespace detail {
17namespace thread {
18
19// class singleton has the same goal as all singletons: create one instance of
20// a class on demand, then dish it out as requested.
21
22template <class T>
23class singleton : private T
24{
25private:
26    singleton();
27    ~singleton();
28
29public:
30    static T &instance();
31};
32
33
34template <class T>
35inline singleton<T>::singleton()
36{
37    /* no-op */
38}
39
40template <class T>
41inline singleton<T>::~singleton()
42{
43    /* no-op */
44}
45
46template <class T>
47/*static*/ T &singleton<T>::instance()
48{
49    // function-local static to force this to work correctly at static
50    // initialization time.
51    static singleton<T> s_oT;
52    return(s_oT);
53}
54
55} // namespace thread
56} // namespace detail
57} // namespace boost
58
59#endif // BOOST_SINGLETON_MJM012402_HPP
Note: See TracBrowser for help on using the repository browser.