17 #ifndef COM_BORA_SOFTWARE__BALAU_UTIL__MEMORY 18 #define COM_BORA_SOFTWARE__BALAU_UTIL__MEMORY 48 template <
typename T,
typename R = T,
typename F,
typename ... P>
49 static std::vector<std::unique_ptr<R>>
makeUnique(F transform,
const T & first,
const P & ... remaining) {
50 std::vector<std::unique_ptr<R>> allItems;
51 allItems.emplace_back(transform(first));
52 std::vector<std::unique_ptr<R>> remainingItems = makeUnique<T, R, F>(transform, remaining ...);
53 std::move(remainingItems.begin(), remainingItems.end(), std::back_inserter(allItems));
66 template <
typename T,
typename R = T,
typename F>
68 return std::vector<std::unique_ptr<R>>();
88 template <
typename T,
typename R = T,
typename F,
typename ... P>
89 static std::vector<std::unique_ptr<R>>
makeUniqueV(F transform,
const T & first,
const P & ... remaining) {
90 std::vector<std::unique_ptr<R>> allItems = transform(first);
91 std::vector<std::unique_ptr<R>> remainingItems = makeUniqueV<T, R, F>(transform, remaining ...);
92 std::move(remainingItems.begin(), remainingItems.end(), std::back_inserter(allItems));
104 template <
typename T,
typename R = T,
typename F>
106 return std::vector<std::shared_ptr<R>>();
125 template <
typename T,
typename R = T,
typename F,
typename ... P>
126 static std::vector<std::shared_ptr<R>>
makeShared(F transform,
const T & first,
const P & ... remaining) {
127 std::vector<std::shared_ptr<R>> allItems;
128 allItems.emplace_back(transform(first));
129 std::vector<std::shared_ptr<R>> remainingItems = makeShared<T, R, F>(transform, remaining ...);
130 std::move(remainingItems.begin(), remainingItems.end(), std::back_inserter(allItems));
142 template <
typename T,
typename R = T,
typename F>
144 return std::vector<std::shared_ptr<R>>();
164 template <
typename T,
typename R = T,
typename F,
typename ... P>
165 static std::vector<std::shared_ptr<R>>
makeSharedV(F transform,
const T & first,
const P & ... remaining) {
166 std::vector<std::shared_ptr<R>> allItems = transform(first);
167 std::vector<std::shared_ptr<R>> remainingItems = makeSharedV<T, R, F>(transform, remaining ...);
168 std::move(remainingItems.begin(), remainingItems.end(), std::back_inserter(allItems));
180 template <
typename T,
typename R = T,
typename F>
182 return std::vector<std::shared_ptr<R>>();
194 #endif // COM_BORA_SOFTWARE__BALAU_UTIL__MEMORY Pre-defined universal to-string functions.
static std::vector< std::unique_ptr< R > > makeUnique(F transform, const T &first, const P &... remaining)
Create a vector of unique pointers after transforming the arguments (scalar transform version)...
Definition: Memory.hpp:49
static std::vector< std::shared_ptr< R > > makeShared(F)
[End case] Create a vector of shared pointers after transforming the arguments (scalar transform vers...
Definition: Memory.hpp:143
static std::vector< std::shared_ptr< R > > makeShared(F transform, const T &first, const P &... remaining)
Create a vector of shared pointers after transforming the arguments (scalar transform version)...
Definition: Memory.hpp:126
static std::vector< std::unique_ptr< R > > makeUnique(F)
[End case] Create a vector of unique pointers after transforming the arguments (scalar transform vers...
Definition: Memory.hpp:67
static std::vector< std::unique_ptr< R > > makeUniqueV(F transform, const T &first, const P &... remaining)
Create a vector of unique pointers after transforming the arguments (vector transform version)...
Definition: Memory.hpp:89
Utilities for memory.
Definition: Memory.hpp:31
static std::vector< std::shared_ptr< R > > makeSharedV(F transform, const T &first, const P &... remaining)
Create a vector of shared pointers after transforming the arguments (vector transform version)...
Definition: Memory.hpp:165
static std::vector< std::shared_ptr< R > > makeSharedV(F)
[End case] Create a vector of shared pointers after transforming the arguments (vector transform vers...
Definition: Memory.hpp:181
static std::vector< std::shared_ptr< R > > makeUniqueV(F)
[End case] Create a vector of unique pointers after transforming the arguments (vector transform vers...
Definition: Memory.hpp:105