WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
PointerUtil.h
1 
11 #ifndef WRENCH_POINTERUTIL_H
12 #define WRENCH_POINTERUTIL_H
13 
14 
15 #include <memory>
16 #include <set>
17 #include <deque>
18 
19 namespace wrench {
20 
21  /***********************/
23  /***********************/
24 
28  class PointerUtil {
29 
30  public:
31 
39  template<class T>
41  typename std::set<std::unique_ptr<T>>::iterator it,
42  std::set<std::unique_ptr<T>> *from,
43  std::set<std::unique_ptr<T>> *to)
44  {
45 
46  auto tmp = const_cast<std::unique_ptr<T>&&>(*it);
47  (*from).erase(it);
48  (*to).insert(std::move(tmp));
49 
50  };
51 
59  template<class T>
61  typename std::set<std::shared_ptr<T>>::iterator it,
62  std::set<std::shared_ptr<T>> *from,
63  std::set<std::shared_ptr<T>> *to)
64  {
65 
66  auto tmp = const_cast<std::shared_ptr<T>&&>(*it);
67  (*from).erase(it);
68  (*to).insert(tmp);
69 
70  };
71 
72 #if 0
73 
80  template<class T>
81  static void moveUniquePtrFromDequeToSet(
82  typename std::deque<std::unique_ptr<T>>::iterator it,
83  std::deque<std::unique_ptr<T>> *from,
84  std::set<std::unique_ptr<T>> *to)
85  {
86 
87  auto tmp = const_cast<std::unique_ptr<T>&&>(*it);
88  (*from).erase(it);
89  (*to).insert(std::move(tmp));
90 
91  };
92 
93 
101  template <class T1>
102  static void moveSingleSeparateUniquePtrFromSetToSet(std::unique_ptr<T1>* ptr,
103  std::set<std::unique_ptr<T1>> *from,
104  std::set<std::unique_ptr<T1>> *to);
105 
106 #endif
107 
108  };
109 
110  /***********************/
112  /***********************/
113 
114 
115 };
116 
117 
118 #endif //WRENCH_POINTERUTIL_H
wrench::PointerUtil::moveUniquePtrFromSetToSet
static void moveUniquePtrFromSetToSet(typename std::set< std::unique_ptr< T >>::iterator it, std::set< std::unique_ptr< T >> *from, std::set< std::unique_ptr< T >> *to)
A helper method to move a unique_ptr from a set to another.
Definition: PointerUtil.h:40
wrench
Definition: Action.cpp:28
wrench::PointerUtil
A helper class that implements useful smart pointer operations.
Definition: PointerUtil.h:28
wrench::PointerUtil::moveSharedPtrFromSetToSet
static void moveSharedPtrFromSetToSet(typename std::set< std::shared_ptr< T >>::iterator it, std::set< std::shared_ptr< T >> *from, std::set< std::shared_ptr< T >> *to)
A helper method to move a shared_ptr from a set to another.
Definition: PointerUtil.h:60