UniqueObject.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef BOOST_STATECHART_EXAMPLE_UNIQUE_OBJECT_HPP_INCLUDED
  2. #define BOOST_STATECHART_EXAMPLE_UNIQUE_OBJECT_HPP_INCLUDED
  3. //////////////////////////////////////////////////////////////////////////////
  4. // Copyright 2002-2006 Andreas Huber Doenni
  5. // Distributed under the Boost Software License, Version 1.0. (See accompany-
  6. // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. //////////////////////////////////////////////////////////////////////////////
  8. #include "UniqueObjectAllocator.hpp"
  9. #include <cstddef> // size_t
  10. //////////////////////////////////////////////////////////////////////////////
  11. template< class Derived >
  12. class UniqueObject
  13. {
  14. public:
  15. //////////////////////////////////////////////////////////////////////////
  16. void * operator new( std::size_t size )
  17. {
  18. return UniqueObjectAllocator< Derived >::allocate( size );
  19. }
  20. void operator delete( void * p, std::size_t size )
  21. {
  22. UniqueObjectAllocator< Derived >::deallocate( p, size );
  23. }
  24. protected:
  25. //////////////////////////////////////////////////////////////////////////
  26. UniqueObject() {}
  27. ~UniqueObject() {}
  28. };
  29. #endif