remove ei_new_allocator

remove corresponding part of test_dynalloc
This commit is contained in:
Benoit Jacob 2009-01-10 02:50:09 +00:00
parent 335d3bcf05
commit 3efe6e4176
2 changed files with 3 additions and 65 deletions

View File

@ -313,10 +313,10 @@ struct WithAlignedOperatorNew
*
* Example:
* \code
* // Vector4f requires 16 bytes alignment:
* std::vector<Vector4f, aligned_allocator<Vector4f> > dataVec4;
* // Matrix4f requires 16 bytes alignment:
* std::map< int, Matrix4f, std::less<int>, aligned_allocator<Matrix4f> > my_map_mat4;
* // Vector3f does not require 16 bytes alignment, no need to use Eigen's allocator:
* std::vector<Vector3f> dataVec3;
* std::map< int, Vector3f > my_map_vec3;
* \endcode
*
*/
@ -392,51 +392,4 @@ public:
}
};
/** \class ei_new_allocator
*
* \brief stl compatible allocator to use with with fixed-size vector and matrix types
*
* STL allocator simply wrapping operators new[] and delete[]. Unlike GCC's default new_allocator,
* ei_new_allocator call operator new on the type \a T and not the general new operator ignoring
* overloaded version of operator new.
*
* Example:
* \code
* // Vector4f requires 16 bytes alignment:
* std::vector<Vector4f,ei_new_allocator<Vector4f> > dataVec4;
* // Vector3f does not require 16 bytes alignment, no need to use Eigen's allocator:
* std::vector<Vector3f> dataVec3;
*
* struct Foo : WithAlignedOperatorNew {
* char dummy;
* Vector4f some_vector;
* };
* std::vector<Foo,ei_new_allocator<Foo> > dataFoo;
* \endcode
*
* \sa class WithAlignedOperatorNew
*/
template<typename T> class ei_new_allocator
{
public:
typedef T value_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
template<typename OtherType>
struct rebind
{ typedef ei_new_allocator<OtherType> other; };
T* address(T& ref) const { return &ref; }
const T* address(const T& ref) const { return &ref; }
T* allocate(size_t size, const void* = 0) { return new T[size]; }
void deallocate(T* ptr, size_t) { delete[] ptr; }
size_t max_size() const { return size_t(-1) / sizeof(T); }
// FIXME I'm note sure about this construction...
void construct(T* ptr, const T& refObj) { ::new(ptr) T(refObj); }
void destroy(T* ptr) { ptr->~T(); }
};
#endif // EIGEN_MEMORY_H

View File

@ -137,20 +137,5 @@ void test_dynalloc()
delete[] foo0;
delete[] fooA;
}
// std::vector
for (int i=0; i<g_repeat*100; ++i)
{
std::vector<Vector4f, ei_new_allocator<Vector4f> > vecs(N);
for (int j=0; j<N; ++j)
{
VERIFY(size_t(vecs[j].data())%16==0);
}
std::vector<MyStruct,ei_new_allocator<MyStruct> > foos(N);
for (int j=0; j<N; ++j)
{
VERIFY(size_t(foos[j].avec.data())%16==0);
}
}
}