[Boost-bugs] [Boost C++ Libraries] #3859: [Boost.utility]

Subject: [Boost-bugs] [Boost C++ Libraries] #3859: [Boost.utility]
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-01-25 16:46:20


#3859: [Boost.utility]
---------------------------------+------------------------------------------
 Reporter: achinkoff@… | Owner: no-maintainer
     Type: Feature Requests | Status: new
Milestone: Boost 1.42.0 | Component: utility
  Version: Boost 1.41.0 | Severity: Optimization
 Keywords: |
---------------------------------+------------------------------------------
 Having considered [http://www.research.ibm.com/designpatterns/pubs/ph-
 jun96.txt]
 I propose singleton implementation.

 I had attached "singleton.hpp" to this letter.

 Below is the test program:


 {{{
 #include <stdio.h>
 #include <singleton.hpp>

 class A : public boost::Singleton<A>
 {
         //
         // Only Singleton class can create and delete us!
         //
         SINGLETON_IS_MY_FRIEND;
 public:
         void foo(){ printf("foo!\n"); }
         A(){ printf("A()\n"); }
         ~A(){ printf("~A()\n"); }
 };

 void main()
 {
         // It is not compiled:
         //A a = A::Instance();
         // That is exactly as it should be used:
         A::Instance().foo();
 }
 }}}


 Test program outputs:

 {{{
 A()
 foo!
 ~A()
 }}}


 I suggest include "singleton.hpp" into "utility.hpp" header that it can be
 used along with: boost::noncopyable, etc.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3859>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC