Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
allocset.h
Go to the documentation of this file.
1 
18 #ifndef ION_BASE_STLALLOC_ALLOCSET_H_
19 #define ION_BASE_STLALLOC_ALLOCSET_H_
20 
21 #include <set>
22 
23 #include "ion/base/allocatable.h"
26 
27 namespace ion {
28 namespace base {
29 
48 
49 template <typename T, typename Compare = std::less<T> >
50 class AllocSet : public std::set<T, Compare, StlAllocator<T> > {
51  public:
53  typedef std::set<T, Compare, AllocType> SetType;
54  explicit AllocSet(const AllocatorPtr& alloc)
55  : SetType(Compare(),
56  AllocType(AllocationManager::GetNonNullAllocator(alloc))) {}
57  explicit AllocSet(const Allocatable& owner)
58  : SetType(Compare(), AllocType(owner.GetNonNullAllocator())) {}
59 
62  template <typename ContainerT>
63  AllocSet(const AllocatorPtr& alloc, const ContainerT& from)
64  : SetType(from.begin(), from.end(), Compare(),
65  AllocType(AllocationManager::GetNonNullAllocator(alloc))) {}
66  template <typename ContainerT>
67  AllocSet(const Allocatable& owner, const ContainerT& from)
68  : SetType(from.begin(), from.end(), Compare(),
69  AllocType(owner.GetNonNullAllocator())) {}
70 
74  AllocSet(const AllocatorPtr& alloc, std::initializer_list<T> init)
75  : SetType(init, Compare(),
76  AllocType(AllocationManager::GetNonNullAllocator(alloc))) {}
77  AllocSet(const Allocatable& owner, std::initializer_list<T> init)
78  : SetType(init, Compare(),
79  AllocType(owner.GetNonNullAllocator())) {}
80 };
81 
82 } // namespace base
83 } // namespace ion
84 
85 #endif // ION_BASE_STLALLOC_ALLOCSET_H_
AllocSet(const Allocatable &owner)
Definition: allocset.h:57
StlAllocator is derived std::allocator class that allows an Ion Allocator to be used for STL containe...
Definition: stlallocator.h:35
AllocSet(const AllocatorPtr &alloc, const ContainerT &from)
These constructors can be used to copy from "STL iterables": anything that provides a pair of compati...
Definition: allocset.h:63
StlAllocator< T > AllocType
Definition: allocset.h:52
AllocSet(const Allocatable &owner, const ContainerT &from)
Definition: allocset.h:67
AllocationManager is a singleton class that is used to manage Allocators used to allocate Ion objects...
AllocSet(const AllocatorPtr &alloc, std::initializer_list< T > init)
These constructors allow AllocSet to be initialized using c++11's list initialization: AllocSet<int> ...
Definition: allocset.h:74
Allocatable is an abstract base class for classes whose memory is managed by an Allocator.
Definition: allocatable.h:60
This class can be used in place of std::set to allow an Ion Allocator to be used for memory allocatio...
Definition: allocset.h:50
AllocSet(const AllocatorPtr &alloc)
Definition: allocset.h:54
AllocSet(const Allocatable &owner, std::initializer_list< T > init)
Definition: allocset.h:77
std::set< T, Compare, AllocType > SetType
Definition: allocset.h:53