KSS Utility
C++ general utilities
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
memory.hpp
Go to the documentation of this file.
1 //
2 // memory.hpp
3 // kssutil
4 //
5 // Created by Steven W. Klassen on 2014-11-23.
6 // Copyright (c) 2014 Klassen Software Solutions. All rights reserved.
7 // Licensing follows the MIT License.
8 //
9 
15 #ifndef kssutil_memory_hpp
16 #define kssutil_memory_hpp
17 
18 namespace kss { namespace util { namespace memory {
19 
28  template <class T>
29  class NullDelete {
30  public:
31  void operator()(T* ptr) const noexcept {}
32  };
33 
37  template <class Iterator, class Allocator>
38  void destroy(Iterator start, Iterator finish, Allocator& allocator) {
39  while (start != finish) {
40  allocator.destroy(start++);
41  }
42  }
43 
47  template <class Iterator, class Allocator>
48  void destroyN(Iterator start, typename Iterator::size_type n, Allocator& allocator) {
49  for (typename Iterator::size_type i = 0; i < n; ++i) {
50  allocator.destroy(start++);
51  }
52  }
53 
54 }}}
55 
56 #endif
void destroy(Iterator start, Iterator finish, Allocator &allocator)
Definition: memory.hpp:38
void operator()(T *ptr) const noexcept
Definition: memory.hpp:31
void destroyN(Iterator start, typename Iterator::size_type n, Allocator &allocator)
Definition: memory.hpp:48
Similar to std::default_delete but does not actually do anything.
Definition: memory.hpp:29