1 #ifndef FWCore_Utilities_SoATupleHelper_h
2 #define FWCore_Utilities_SoATupleHelper_h
35 return (iBoundary - iSizeSoFar % iBoundary) % iBoundary;
43 template<
unsigned int I,
unsigned int J,
typename Ret,
typename...
Args>
47 template<
unsigned int I,
unsigned int J,
typename Ret,
typename F,
typename...
Args>
55 template<
unsigned int I,
typename Ret,
typename F,
typename...
Args>
66 template<
typename T,
unsigned int ALIGNMENT>
86 template<
typename T,
unsigned int ALIGNMENT>
96 template<
unsigned int I,
typename...
Args>
107 static size_t moveToNew(
char* iNewMemory,
size_t iSize,
size_t iReserve,
void** oToSet);
108 static size_t copyToNew(
char* iNewMemory,
size_t iSize,
size_t iReserve,
void*
const* iFrom,
void** oToSet);
110 static void push_back(
void** iToSet,
size_t iSize, std::tuple<Args...>
const& iValues);
111 template<
typename... FArgs>
112 static void emplace_back(
void** iToSet,
size_t iSize, FArgs... iValues);
113 static void destroy(
void** iToSet,
size_t iSize);
123 template<
typename...
Args>
129 static void push_back(
void** ,
size_t , std::tuple<Args...>
const& ) {
132 template<
typename... FArgs>
133 static void emplace_back(
void** iToSet,
size_t iSize, FArgs... iValues) {}
139 static size_t moveToNew(
char* ,
size_t ,
size_t ,
void** ) {
143 static size_t copyToNew(
char* ,
size_t ,
size_t ,
void*
const* ,
void** ) {
148 template<
unsigned int I,
typename...
Args>
150 size_t usedSoFar = NextHelper::moveToNew(iNewMemory,iSize, iReserve, oToSet);
153 const unsigned int boundary = AlignmentInfo::kAlignment;
157 void** oldStart = oToSet+
I-1;
159 Type* oldValues =
static_cast<Type*
>(*oldStart);
160 if(oldValues !=
nullptr ) {
162 for(
auto it = oldValues; it != oldValues+iSize; ++it,++ptr) {
163 new (ptr)
Type(std::move(*it));
165 for(
auto it = oldValues; it != oldValues+iSize; ++it) {
169 *oldStart = newStart;
170 unsigned int additionalSize =
padding_needed(usedSoFar,boundary) + iReserve*
sizeof(
Type);
171 return usedSoFar+additionalSize;
174 template<
unsigned int I,
typename...
Args>
176 size_t usedSoFar = NextHelper::copyToNew(iNewMemory,iSize, iReserve, iFrom, oToSet);
179 const unsigned int boundary = AlignmentInfo::kAlignment;
183 void*
const* oldStart = iFrom+
I-1;
185 Type* oldValues =
static_cast<Type*
>(*oldStart);
186 if(oldValues !=
nullptr ) {
188 for(
auto it = oldValues; it != oldValues+iSize; ++it,++ptr) {
192 *(oToSet+I-1) = newStart;
193 unsigned int additionalSize =
padding_needed(usedSoFar,boundary) + iReserve*
sizeof(
Type);
194 return usedSoFar+additionalSize;
198 template<
unsigned int I,
typename...
Args>
200 size_t usedSoFar = NextHelper::spaceNeededFor(iNElements);
201 const unsigned int boundary = AlignmentInfo::kAlignment;
202 unsigned int additionalSize =
padding_needed(usedSoFar,boundary) + iNElements*
sizeof(
Type);
203 return usedSoFar+additionalSize;
206 template<
unsigned int I,
typename...
Args>
208 new (
static_cast<Type*
>(*(iToSet+
I-1))+iSize)
Type(std::get<I-1>(iValues));
210 NextHelper::push_back(iToSet,iSize,iValues);
213 template<
unsigned int I,
typename...
Args>
214 template<
typename ... FArgs>
218 NextHelper::emplace_back(iToSet,iSize,std::forward<FArgs>(iValues)...);
221 template<
unsigned int I,
typename...
Args>
223 void**
start = iToSet+
I-1;
226 for(
auto it = values; it != values+iSize; ++it) {
static size_t moveToNew(char *iNewMemory, size_t iSize, size_t iReserve, void **oToSet)
tuple start
Check for commandline option errors.
static void destroy(void **, size_t)
static void push_back(void **iToSet, size_t iSize, std::tuple< Args...> const &iValues)
SoATupleHelper< I-1, Args...> NextHelper
static size_t copyToNew(char *, size_t, size_t, void *const *, void **)
static void emplace_back(void **iToSet, size_t iSize, FArgs...iValues)
static size_t copyToNew(char *iNewMemory, size_t iSize, size_t iReserve, void *const *iFrom, void **oToSet)
static size_t spaceNeededFor(unsigned int)
const SoATupleHelper & operator=(const SoATupleHelper &)=delete
const std::complex< double > I
static Ret pull(F const &, const Args &...args)
static void emplace_back(void **iToSet, size_t iSize, FArgs...iValues)
static const std::size_t max_alignment
SoATupleHelper(const SoATupleHelper &)=delete
static Ret pull(F const &iV, const Args &...)
AlignmentHelper< typename std::tuple_element< I-1, std::tuple< Args...> >::type > AlignmentInfo
static const unsigned int kAlignment
static void push_back(void **, size_t, std::tuple< Args...> const &)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
static size_t spaceNeededFor(unsigned int iNElements)
static size_t moveToNew(char *, size_t, size_t, void **)
constexpr unsigned int padding_needed(size_t iSizeSoFar, unsigned int iBoundary)
static void destroy(void **iToSet, size_t iSize)
static const std::size_t kAlignment