Ticket #3435: trivial_singleton.hpp.patch
File trivial_singleton.hpp.patch, 1.5 KB (added by , 13 years ago) |
---|
-
./boost/test/utils/
old new 35 35 template<typename Derived> 36 36 class singleton : private boost::noncopyable { 37 37 public: 38 static Derived& instance() { static Derived the_inst; return the_inst; }38 static Derived& instance(); 39 39 protected: 40 40 singleton() {} 41 41 ~singleton() {} 42 42 }; 43 43 44 } // namespace unit_test 44 45 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) 46 template< typename T > 47 T& get_static_instance() 48 { 49 static T inst; 50 return inst; 51 } 52 53 template<typename Derived> 54 inline Derived& singleton< Derived >::instance() 55 { 56 return get_static_instance< Derived >(); 57 } 58 59 #define BOOST_TEST_SINGLETON_CONS( type ) \ 60 template< typename T > friend T& boost::unit_test::get_static_instance(); \ 61 type() {} \ 62 /**/ 63 64 #else // BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) 65 66 template<typename Derived> 67 inline Derived& singleton< Derived >::instance() 68 { 69 static Derived the_inst; 70 return the_inst; 71 } 45 72 46 73 #define BOOST_TEST_SINGLETON_CONS( type ) \ 47 74 friend class boost::unit_test::singleton<type>; \ 48 75 type() {} \ 49 76 /**/ 50 77 78 #endif // BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) 79 80 } // namespace unit_test 81 82 51 83 #if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) 52 84 53 85 #define BOOST_TEST_SINGLETON_INST( inst ) \