lean cpp library
A lean C++ library providing efficient utility classes for high-performance C++ applications.
|
00001 /*****************************************************/ 00002 /* lean Memory (c) Tobias Zirr 2011 */ 00003 /*****************************************************/ 00004 00005 #ifndef LEAN_MEMORY_HEAP_BOUND 00006 #define LEAN_MEMORY_HEAP_BOUND 00007 00008 #include "../lean.h" 00009 #include "default_heap.h" 00010 00011 namespace lean 00012 { 00013 namespace memory 00014 { 00017 template <class Heap = default_heap> 00018 class heap_bound 00019 { 00020 protected: 00021 LEAN_INLINE heap_bound() { }; 00022 #ifndef LEAN_OPTIMIZE_DEFAULT_DESTRUCTOR 00023 LEAN_INLINE ~heap_bound() throw() { }; 00024 #endif 00025 00026 public: 00028 LEAN_INLINE void* operator new(size_t size) 00029 { 00030 return Heap::allocate(size); 00031 } 00033 LEAN_INLINE void operator delete(void *memory) 00034 { 00035 Heap::free(memory); 00036 } 00038 LEAN_INLINE void* operator new[](size_t size) 00039 { 00040 return Heap::allocate(size); 00041 } 00043 LEAN_INLINE void operator delete[](void *memory) 00044 { 00045 Heap::free(memory); 00046 } 00047 }; 00048 00049 } // namespace 00050 00051 using memory::heap_bound; 00052 00053 } // namespace 00054 00055 #endif