123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #ifndef BOOST_CONTAINER_DETAIL_SINGLETON_DETAIL_HPP
- #define BOOST_CONTAINER_DETAIL_SINGLETON_DETAIL_HPP
- #ifndef BOOST_CONFIG_HPP
- # include <boost/config.hpp>
- #endif
- #if defined(BOOST_HAS_PRAGMA_ONCE)
- # pragma once
- #endif
- #include <boost/container/detail/config_begin.hpp>
- #include <boost/container/detail/workaround.hpp>
- namespace boost {
- namespace container {
- namespace dtl {
- template <typename T>
- struct singleton_default
- {
- private:
- struct object_creator
- {
-
-
-
- object_creator() { singleton_default<T>::instance(); }
- inline void do_nothing() const { }
- };
- static object_creator create_object;
- singleton_default();
- public:
- typedef T object_type;
-
-
- static object_type & instance()
- {
-
-
-
- static object_type obj;
-
-
-
- create_object.do_nothing();
- return obj;
- }
- };
- template <typename T>
- typename singleton_default<T>::object_creator
- singleton_default<T>::create_object;
- }
- }
- }
- #include <boost/container/detail/config_end.hpp>
- #endif
|