From 229bcfde08a05f1ef7a237bc8b9a02d12e175798 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Wed, 28 Mar 2001 02:43:30 +0000 Subject: [PATCH] changed to John's version of static_object [SVN r9664] --- include/boost/concept_archetype.hpp | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/include/boost/concept_archetype.hpp b/include/boost/concept_archetype.hpp index e1d8ad5..b8a01be 100644 --- a/include/boost/concept_archetype.hpp +++ b/include/boost/concept_archetype.hpp @@ -40,30 +40,16 @@ namespace boost { }; // This is a helper class that provides a way to get a reference to - // an object. + // an object. The get() function will never be called at run-time + // (nothing in this file will) so this seemingly very bad function + // is really quite innocent. The name of this class needs to be + // changed. template class static_object { public: static T& get() { - detail::dummy_constructor d; - static T x(d); - return x; - } - }; - template <> - class static_object { - public: - static bool& get() { - static bool b; - return b; - } - }; - template <> - class static_object { - public: - static int& get() { - static int b; - return b; + char d[sizeof(T)]; + return *reinterpret_cast(d); } };