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>
52 template <
unsigned int I,
typename Ret,
typename F,
typename... Args>
54 static Ret
pull(
F const& iV,
const Args&...) {
return iV; }
61 template <
typename T,
unsigned int ALIGNMENT>
80 template <
typename T,
unsigned int ALIGNMENT>
90 template <
unsigned int I,
typename... Args>
100 static size_t moveToNew(
char* iNewMemory,
size_t iSize,
size_t iReserve,
void** oToSet);
101 static size_t copyToNew(
char* iNewMemory,
size_t iSize,
size_t iReserve,
void*
const* iFrom,
void** oToSet);
103 static void push_back(
void** iToSet,
size_t iSize, std::tuple<Args...>
const& iValues);
104 template <
typename... FArgs>
105 static void emplace_back(
void** iToSet,
size_t iSize, FArgs... iValues);
106 static void destroy(
void** iToSet,
size_t iSize);
115 template <
typename... Args>
120 static void push_back(
void** ,
size_t , std::tuple<Args...>
const& ) {}
122 template <
typename... FArgs>
123 static void emplace_back(
void** iToSet,
size_t iSize, FArgs... iValues) {}
127 static size_t moveToNew(
char* ,
size_t ,
size_t ,
void** ) {
132 char* ,
size_t ,
size_t ,
void*
const* ,
void** ) {
137 template <
unsigned int I,
typename... Args>
139 size_t usedSoFar = NextHelper::moveToNew(iNewMemory, iSize, iReserve, oToSet);
142 const unsigned int boundary = AlignmentInfo::kAlignment;
146 void** oldStart = oToSet +
I - 1;
148 Type* oldValues =
static_cast<Type*
>(*oldStart);
149 if (oldValues !=
nullptr) {
151 for (
auto it = oldValues;
it != oldValues + iSize; ++
it, ++ptr) {
154 for (
auto it = oldValues;
it != oldValues + iSize; ++
it) {
158 *oldStart = newStart;
159 unsigned int additionalSize =
padding_needed(usedSoFar, boundary) + iReserve *
sizeof(
Type);
160 return usedSoFar + additionalSize;
163 template <
unsigned int I,
typename... Args>
165 char* iNewMemory,
size_t iSize,
size_t iReserve,
void*
const* iFrom,
void** oToSet) {
166 size_t usedSoFar = NextHelper::copyToNew(iNewMemory, iSize, iReserve, iFrom, oToSet);
169 const unsigned int boundary = AlignmentInfo::kAlignment;
173 void*
const* oldStart = iFrom +
I - 1;
175 Type* oldValues =
static_cast<Type*
>(*oldStart);
176 if (oldValues !=
nullptr) {
178 for (
auto it = oldValues;
it != oldValues + iSize; ++
it, ++ptr) {
182 *(oToSet +
I - 1) = newStart;
183 unsigned int additionalSize =
padding_needed(usedSoFar, boundary) + iReserve *
sizeof(
Type);
184 return usedSoFar + additionalSize;
187 template <
unsigned int I,
typename... Args>
189 size_t usedSoFar = NextHelper::spaceNeededFor(iNElements);
190 const unsigned int boundary = AlignmentInfo::kAlignment;
191 unsigned int additionalSize =
padding_needed(usedSoFar, boundary) + iNElements *
sizeof(
Type);
192 return usedSoFar + additionalSize;
195 template <
unsigned int I,
typename... Args>
197 new (
static_cast<Type*
>(*(iToSet +
I - 1)) + iSize)
Type(std::get<I - 1>(iValues));
202 template <
unsigned int I,
typename... Args>
203 template <
typename... FArgs>
205 new (
static_cast<Type*
>(*(iToSet +
I - 1)) + iSize)
208 NextHelper::emplace_back(iToSet, iSize, std::forward<FArgs>(iValues)...);
211 template <
unsigned int I,
typename... Args>
213 void**
start = iToSet +
I - 1;
220 NextHelper::destroy(iToSet, iSize);
static size_t moveToNew(char *iNewMemory, size_t iSize, size_t iReserve, void **oToSet)
static size_t moveToNew(char *, size_t, size_t, void **)
static void destroy(void **, size_t)
AlignmentHelper< typename std::tuple_element< I - 1, std::tuple< Args... > >::type > AlignmentInfo
static size_t copyToNew(char *, size_t, size_t, void *const *, void **)
static void emplace_back(void **iToSet, size_t iSize, FArgs... iValues)
static void push_back(void **iToSet, size_t iSize, std::tuple< Args... > const &iValues)
static size_t copyToNew(char *iNewMemory, size_t iSize, size_t iReserve, void *const *iFrom, void **oToSet)
const SoATupleHelper & operator=(const SoATupleHelper &)=delete
const std::complex< double > I
static void emplace_back(void **iToSet, size_t iSize, FArgs... iValues)
SoATupleHelper< I - 1, Args... > NextHelper
static const std::size_t max_alignment
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
SoATupleHelper(const SoATupleHelper &)=delete
static void push_back(void **, size_t, std::tuple< Args... > const &)
static const unsigned int kAlignment
static Ret pull(F const &iV, const Args &...)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
static size_t spaceNeededFor(unsigned int iNElements)
static size_t spaceNeededFor(unsigned int)
static Ret pull(F const &, const Args &... args)
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