1 // (C) Copyright Gennadiy Rozental 2001.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 // See http://www.boost.org/libs/test for the library home page.
10 // Version : $Revision$
12 // Description : simple helpers for creating cusom output manipulators
13 // ***************************************************************************
15 #ifndef BOOST_TEST_UTILS_TRIVIAL_SIGNLETON_HPP
16 #define BOOST_TEST_UTILS_TRIVIAL_SIGNLETON_HPP
19 #include <boost/config.hpp>
20 #include <boost/detail/workaround.hpp>
23 #include <boost/test/detail/suppress_warnings.hpp>
25 //____________________________________________________________________________//
30 // ************************************************************************** //
31 // ************** singleton ************** //
32 // ************************************************************************** //
34 template<typename Derived>
37 static Derived& instance() { static Derived the_inst; return the_inst; }
39 BOOST_DELETED_FUNCTION(singleton(singleton const&))
40 BOOST_DELETED_FUNCTION(singleton& operator=(singleton const&))
43 BOOST_DEFAULTED_FUNCTION(singleton(), {})
44 BOOST_DEFAULTED_FUNCTION(~singleton(), {})
47 //____________________________________________________________________________//
49 #define BOOST_TEST_SINGLETON_CONS( type ) \
50 friend class boost::unit_test::singleton<type>; \
54 #if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
56 #define BOOST_TEST_SINGLETON_INST( inst ) \
57 template class unit_test::singleton< BOOST_JOIN( inst, _t ) > ; \
58 namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
60 #elif defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4
61 #define BOOST_TEST_SINGLETON_INST( inst ) \
62 static BOOST_JOIN( inst, _t)& inst = BOOST_JOIN (inst, _t)::instance();
66 #define BOOST_TEST_SINGLETON_INST( inst ) \
67 namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
71 //____________________________________________________________________________//
73 } // namespace unit_test
77 #include <boost/test/detail/enable_warnings.hpp>
79 #endif // BOOST_TEST_UTILS_TRIVIAL_SIGNLETON_HPP