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 | |
9 | |
10 | |
11 | #include "UniqueObjectAllocator.hpp" |
12 | |
13 | #include <cstddef> // size_t |
14 | |
15 | |
16 | |
17 | ////////////////////////////////////////////////////////////////////////////// |
18 | template< class Derived > |
19 | class UniqueObject |
20 | { |
21 | public: |
22 | ////////////////////////////////////////////////////////////////////////// |
23 | void * operator new( std::size_t size ) |
24 | { |
25 | return UniqueObjectAllocator< Derived >::allocate( size ); |
26 | } |
27 | |
28 | void operator delete( void * p, std::size_t size ) |
29 | { |
30 | UniqueObjectAllocator< Derived >::deallocate( p, size ); |
31 | } |
32 | |
33 | protected: |
34 | ////////////////////////////////////////////////////////////////////////// |
35 | UniqueObject() {} |
36 | ~UniqueObject() {} |
37 | }; |
38 | |
39 | |
40 | |
41 | #endif |
42 | |