remove emacs bak file + fixes

This commit is contained in:
Christian Zimmermann 2019-02-27 20:41:46 +01:00
parent b0063bb9e2
commit 9fec5d6354
2 changed files with 7 additions and 63 deletions

View file

@ -1,62 +0,0 @@
#ifndef __ma_allocator__
#define __ma_allocator__
#include <cstdlib>
#include <new>
#include <vector>
namespace MultiArrayHelper
{
template <typename T, size_t N>
struct Allocator
{
typedef T value_type;
static constexpr type_size = sizeof(value_type);
Allocator() = default;
template <typename U>
Allocator(const Allocator<U>& x) {}
T* allocate(size_t n)
{
//constexpr size_t NN = N*type_size;
const size_t nn = n*type_size;
if(n > static_cast<size_t>(-1-NN)) throw std::bad_alloc();
auto p = static_cast<char*>(std::malloc(nn + N));
if(not p) throw std::bad_alloc();
auto ip = static_cast<std::intptr_t>(p);
mDiff = N - (ip % N);
p += mDiff;
return static_cast<T*>(p);
}
void deacllocate(T* p, size_t n)
{
std::free(p-mDiff);
}
private:
std::intptr_t mDiff;
};
template <class T, class U>
bool operator==(const Allocator<T>& a, const Allocator<T>& b)
{
return true;
}
template <class T, class U>
bool operator!=(const Allocator<T>& a, const Allocator<T>& b)
{
return false;
}
template <typename T>
using vector = vector<T,Allocator>;
} // namespace MultiArrayHelper
#endif

View file

@ -234,6 +234,7 @@ namespace MultiArrayTools
{
//VCHECK(ma.data());
mIndex(indices...);
mDataPtr = mOrigDataPtr + mIndex.pos();
//mOff = mIndex.pos();
}
@ -247,6 +248,7 @@ namespace MultiArrayTools
mMaPtr(maptr)
{
mIndex(indices...);
mDataPtr = mOrigDataPtr + mIndex.pos();
//mOff = mIndex.pos();
}
@ -257,6 +259,7 @@ namespace MultiArrayTools
mOrigDataPtr(data),
mIndex( ind )
{
mDataPtr = mOrigDataPtr + mIndex.pos();
//mOff = mIndex.pos();
}
@ -279,7 +282,8 @@ namespace MultiArrayTools
template <typename T, class... Ranges>
const T* ConstOperationRoot<T,Ranges...>::data() const
{
return mDataPtr + mIndex().pos();
auto i = mIndex;
return mDataPtr + i().pos();
}
template <typename T, class... Ranges>
@ -392,6 +396,7 @@ namespace MultiArrayTools
mIndex( ma.begin() )
{
mIndex(indices...);
mDataPtr = mOrigDataPtr + mIndex.pos();
//mOff = mIndex.pos();
}
@ -402,6 +407,7 @@ namespace MultiArrayTools
mOrigDataPtr(data),
mIndex( ind )
{
mDataPtr = mOrigDataPtr + mIndex.pos();
//mOff = mIndex.pos();
}