1 #ifndef FWCore_Utilities_SoATupleHelper_h
2 #define FWCore_Utilities_SoATupleHelper_h
34 return (iBoundary - iSizeSoFar % iBoundary) % iBoundary;
42 template<
unsigned int I,
unsigned int J,
typename Ret,
typename...
Args>
46 template<
unsigned int I,
unsigned int J,
typename Ret,
typename F,
typename...
Args>
54 template<
unsigned int I,
typename Ret,
typename F,
typename...
Args>
65 template<
typename T,
unsigned int ALIGNMENT>
85 template<
typename T,
unsigned int ALIGNMENT>
95 template<
unsigned int I,
typename...
Args>
106 static size_t moveToNew(
char* iNewMemory,
size_t iSize,
size_t iReserve,
void** oToSet);
107 static size_t copyToNew(
char* iNewMemory,
size_t iSize,
size_t iReserve,
void*
const* iFrom,
void** oToSet);
109 static void push_back(
void** iToSet,
size_t iSize, std::tuple<Args...>
const& iValues);
110 template<
typename... FArgs>
122 template<
typename...
Args>
128 static void push_back(
void** ,
size_t , std::tuple<Args...>
const& ) {
131 template<
typename... FArgs>
138 static size_t moveToNew(
char* ,
size_t ,
size_t ,
void** ) {
142 static size_t copyToNew(
char* ,
size_t ,
size_t ,
void*
const* ,
void** ) {
147 template<
unsigned int I,
typename...
Args>
149 size_t usedSoFar = NextHelper::moveToNew(iNewMemory,iSize, iReserve, oToSet);
152 const unsigned int boundary = AlignmentInfo::kAlignment;
156 void** oldStart = oToSet+
I-1;
158 Type* oldValues =
static_cast<Type*
>(*oldStart);
159 if(oldValues !=
nullptr ) {
161 for(
auto it = oldValues; it != oldValues+
iSize; ++it,++ptr) {
164 for(
auto it = oldValues; it != oldValues+
iSize; ++it) {
168 *oldStart = newStart;
169 unsigned int additionalSize =
padding_needed(usedSoFar,boundary) + iReserve*
sizeof(
Type);
170 return usedSoFar+additionalSize;
173 template<
unsigned int I,
typename...
Args>
175 size_t usedSoFar = NextHelper::copyToNew(iNewMemory,iSize, iReserve, iFrom, oToSet);
178 const unsigned int boundary = AlignmentInfo::kAlignment;
182 void*
const* oldStart = iFrom+
I-1;
184 Type* oldValues =
static_cast<Type*
>(*oldStart);
185 if(oldValues !=
nullptr ) {
187 for(
auto it = oldValues; it != oldValues+
iSize; ++it,++ptr) {
191 *(oToSet+I-1) = newStart;
192 unsigned int additionalSize =
padding_needed(usedSoFar,boundary) + iReserve*
sizeof(
Type);
193 return usedSoFar+additionalSize;
197 template<
unsigned int I,
typename...
Args>
199 size_t usedSoFar = NextHelper::spaceNeededFor(iNElements);
200 const unsigned int boundary = AlignmentInfo::kAlignment;
201 unsigned int additionalSize =
padding_needed(usedSoFar,boundary) + iNElements*
sizeof(
Type);
202 return usedSoFar+additionalSize;
205 template<
unsigned int I,
typename...
Args>
207 new (
static_cast<Type*
>(*(iToSet+
I-1))+
iSize)
Type(std::get<I-1>(iValues));
209 NextHelper::push_back(iToSet,iSize,iValues);
212 template<
unsigned int I,
typename...
Args>
213 template<
typename ... FArgs>
217 NextHelper::emplace_back(iToSet,iSize,std::forward<FArgs>(iValues)...);
220 template<
unsigned int I,
typename...
Args>
222 void**
start = iToSet+
I-1;
225 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