Add std:: namespace prefix to all (hopefully) instances if size_t/ptrdfiff_t

This commit is contained in:
Gael Guennebaud 2017-01-23 22:02:53 +01:00
parent 5202bc92e6
commit 4b2e7f26aa
8 changed files with 50 additions and 50 deletions

View File

@ -14,7 +14,7 @@
#include "src/Core/util/DisableStupidWarnings.h" #include "src/Core/util/DisableStupidWarnings.h"
void *qMalloc(size_t size) void *qMalloc(std::size_t size)
{ {
return Eigen::internal::aligned_malloc(size); return Eigen::internal::aligned_malloc(size);
} }
@ -24,7 +24,7 @@ void qFree(void *ptr)
Eigen::internal::aligned_free(ptr); Eigen::internal::aligned_free(ptr);
} }
void *qRealloc(void *ptr, size_t size) void *qRealloc(void *ptr, std::size_t size)
{ {
void* newPtr = Eigen::internal::aligned_malloc(size); void* newPtr = Eigen::internal::aligned_malloc(size);
memcpy(newPtr, ptr, size); memcpy(newPtr, ptr, size);

View File

@ -41,7 +41,7 @@ template<> struct check_rows_cols_for_overflow<Dynamic> {
{ {
// http://hg.mozilla.org/mozilla-central/file/6c8a909977d3/xpcom/ds/CheckedInt.h#l242 // http://hg.mozilla.org/mozilla-central/file/6c8a909977d3/xpcom/ds/CheckedInt.h#l242
// we assume Index is signed // we assume Index is signed
Index max_index = (size_t(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed Index max_index = (std::size_t(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed
bool error = (rows == 0 || cols == 0) ? false bool error = (rows == 0 || cols == 0) ? false
: (rows > max_index / cols); : (rows > max_index / cols);
if (error) if (error)

View File

@ -65,7 +65,7 @@ template<> struct unpacket_traits<Packet2cf> { typedef std::complex<float> type;
template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>& from) template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>& from)
{ {
Packet2cf res; Packet2cf res;
if((ptrdiff_t(&from) % 16) == 0) if((std::ptrdiff_t(&from) % 16) == 0)
res.v = pload<Packet4f>((const float *)&from); res.v = pload<Packet4f>((const float *)&from);
else else
res.v = ploadu<Packet4f>((const float *)&from); res.v = ploadu<Packet4f>((const float *)&from);

View File

@ -90,7 +90,7 @@ static Packet16uc p16uc_DUPLICATE32_HI = { 0,1,2,3, 0,1,2,3, 4,5,6,7, 4,5,6,7 };
#define _EIGEN_MASK_ALIGNMENT 0xfffffff0 #define _EIGEN_MASK_ALIGNMENT 0xfffffff0
#endif #endif
#define _EIGEN_ALIGNED_PTR(x) ((ptrdiff_t)(x) & _EIGEN_MASK_ALIGNMENT) #define _EIGEN_ALIGNED_PTR(x) ((std::ptrdiff_t)(x) & _EIGEN_MASK_ALIGNMENT)
// Handle endianness properly while loading constants // Handle endianness properly while loading constants
// Define global static constants: // Define global static constants:
@ -450,15 +450,15 @@ template<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float* from)
template<> EIGEN_STRONG_INLINE Packet4f ploaddup<Packet4f>(const float* from) template<> EIGEN_STRONG_INLINE Packet4f ploaddup<Packet4f>(const float* from)
{ {
Packet4f p; Packet4f p;
if((ptrdiff_t(from) % 16) == 0) p = pload<Packet4f>(from); if((std::ptrdiff_t(from) % 16) == 0) p = pload<Packet4f>(from);
else p = ploadu<Packet4f>(from); else p = ploadu<Packet4f>(from);
return vec_perm(p, p, p16uc_DUPLICATE32_HI); return vec_perm(p, p, p16uc_DUPLICATE32_HI);
} }
template<> EIGEN_STRONG_INLINE Packet4i ploaddup<Packet4i>(const int* from) template<> EIGEN_STRONG_INLINE Packet4i ploaddup<Packet4i>(const int* from)
{ {
Packet4i p; Packet4i p;
if((ptrdiff_t(from) % 16) == 0) p = pload<Packet4i>(from); if((std::ptrdiff_t(from) % 16) == 0) p = pload<Packet4i>(from);
else p = ploadu<Packet4i>(from); else p = ploadu<Packet4i>(from);
return vec_perm(p, p, p16uc_DUPLICATE32_HI); return vec_perm(p, p, p16uc_DUPLICATE32_HI);
} }
@ -935,8 +935,8 @@ template<> EIGEN_STRONG_INLINE Packet2d ploadu<Packet2d>(const double* from)
template<> EIGEN_STRONG_INLINE Packet2d ploaddup<Packet2d>(const double* from) template<> EIGEN_STRONG_INLINE Packet2d ploaddup<Packet2d>(const double* from)
{ {
Packet2d p; Packet2d p;
if((ptrdiff_t(from) % 16) == 0) p = pload<Packet2d>(from); if((std::ptrdiff_t(from) % 16) == 0) p = pload<Packet2d>(from);
else p = ploadu<Packet2d>(from); else p = ploadu<Packet2d>(from);
return vec_splat_dbl<0>(p); return vec_splat_dbl<0>(p);
} }

View File

@ -100,7 +100,7 @@ static Packet16uc p16uc_DUPLICATE32_HI = { 0,1,2,3, 0,1,2,3, 4,5,6,7, 4,5,6,7 };
// Mask alignment // Mask alignment
#define _EIGEN_MASK_ALIGNMENT 0xfffffffffffffff0 #define _EIGEN_MASK_ALIGNMENT 0xfffffffffffffff0
#define _EIGEN_ALIGNED_PTR(x) ((ptrdiff_t)(x) & _EIGEN_MASK_ALIGNMENT) #define _EIGEN_ALIGNED_PTR(x) ((std::ptrdiff_t)(x) & _EIGEN_MASK_ALIGNMENT)
// Handle endianness properly while loading constants // Handle endianness properly while loading constants
// Define global static constants: // Define global static constants:

View File

@ -150,7 +150,7 @@ EIGEN_DEVICE_FUNC inline void check_that_malloc_is_allowed()
/** \internal Allocates \a size bytes. The returned pointer is guaranteed to have 16 or 32 bytes alignment depending on the requirements. /** \internal Allocates \a size bytes. The returned pointer is guaranteed to have 16 or 32 bytes alignment depending on the requirements.
* On allocation error, the returned pointer is null, and std::bad_alloc is thrown. * On allocation error, the returned pointer is null, and std::bad_alloc is thrown.
*/ */
EIGEN_DEVICE_FUNC inline void* aligned_malloc(size_t size) EIGEN_DEVICE_FUNC inline void* aligned_malloc(std::size_t size)
{ {
check_that_malloc_is_allowed(); check_that_malloc_is_allowed();
@ -185,7 +185,7 @@ EIGEN_DEVICE_FUNC inline void aligned_free(void *ptr)
* \brief Reallocates an aligned block of memory. * \brief Reallocates an aligned block of memory.
* \throws std::bad_alloc on allocation failure * \throws std::bad_alloc on allocation failure
*/ */
inline void* aligned_realloc(void *ptr, size_t new_size, size_t old_size) inline void* aligned_realloc(void *ptr, std::size_t new_size, std::size_t old_size)
{ {
EIGEN_UNUSED_VARIABLE(old_size); EIGEN_UNUSED_VARIABLE(old_size);
@ -209,12 +209,12 @@ inline void* aligned_realloc(void *ptr, size_t new_size, size_t old_size)
/** \internal Allocates \a size bytes. If Align is true, then the returned ptr is 16-byte-aligned. /** \internal Allocates \a size bytes. If Align is true, then the returned ptr is 16-byte-aligned.
* On allocation error, the returned pointer is null, and a std::bad_alloc is thrown. * On allocation error, the returned pointer is null, and a std::bad_alloc is thrown.
*/ */
template<bool Align> EIGEN_DEVICE_FUNC inline void* conditional_aligned_malloc(size_t size) template<bool Align> EIGEN_DEVICE_FUNC inline void* conditional_aligned_malloc(std::size_t size)
{ {
return aligned_malloc(size); return aligned_malloc(size);
} }
template<> EIGEN_DEVICE_FUNC inline void* conditional_aligned_malloc<false>(size_t size) template<> EIGEN_DEVICE_FUNC inline void* conditional_aligned_malloc<false>(std::size_t size)
{ {
check_that_malloc_is_allowed(); check_that_malloc_is_allowed();
@ -235,12 +235,12 @@ template<> EIGEN_DEVICE_FUNC inline void conditional_aligned_free<false>(void *p
std::free(ptr); std::free(ptr);
} }
template<bool Align> inline void* conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) template<bool Align> inline void* conditional_aligned_realloc(void* ptr, std::size_t new_size, std::size_t old_size)
{ {
return aligned_realloc(ptr, new_size, old_size); return aligned_realloc(ptr, new_size, old_size);
} }
template<> inline void* conditional_aligned_realloc<false>(void* ptr, size_t new_size, size_t) template<> inline void* conditional_aligned_realloc<false>(void* ptr, std::size_t new_size, std::size_t)
{ {
return std::realloc(ptr, new_size); return std::realloc(ptr, new_size);
} }
@ -252,7 +252,7 @@ template<> inline void* conditional_aligned_realloc<false>(void* ptr, size_t new
/** \internal Destructs the elements of an array. /** \internal Destructs the elements of an array.
* The \a size parameters tells on how many objects to call the destructor of T. * The \a size parameters tells on how many objects to call the destructor of T.
*/ */
template<typename T> EIGEN_DEVICE_FUNC inline void destruct_elements_of_array(T *ptr, size_t size) template<typename T> EIGEN_DEVICE_FUNC inline void destruct_elements_of_array(T *ptr, std::size_t size)
{ {
// always destruct an array starting from the end. // always destruct an array starting from the end.
if(ptr) if(ptr)
@ -262,9 +262,9 @@ template<typename T> EIGEN_DEVICE_FUNC inline void destruct_elements_of_array(T
/** \internal Constructs the elements of an array. /** \internal Constructs the elements of an array.
* The \a size parameter tells on how many objects to call the constructor of T. * The \a size parameter tells on how many objects to call the constructor of T.
*/ */
template<typename T> EIGEN_DEVICE_FUNC inline T* construct_elements_of_array(T *ptr, size_t size) template<typename T> EIGEN_DEVICE_FUNC inline T* construct_elements_of_array(T *ptr, std::size_t size)
{ {
size_t i; std::size_t i;
EIGEN_TRY EIGEN_TRY
{ {
for (i = 0; i < size; ++i) ::new (ptr + i) T; for (i = 0; i < size; ++i) ::new (ptr + i) T;
@ -283,9 +283,9 @@ template<typename T> EIGEN_DEVICE_FUNC inline T* construct_elements_of_array(T *
*****************************************************************************/ *****************************************************************************/
template<typename T> template<typename T>
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void check_size_for_overflow(size_t size) EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void check_size_for_overflow(std::size_t size)
{ {
if(size > size_t(-1) / sizeof(T)) if(size > std::size_t(-1) / sizeof(T))
throw_std_bad_alloc(); throw_std_bad_alloc();
} }
@ -293,7 +293,7 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void check_size_for_overflow(size_t size)
* On allocation error, the returned pointer is undefined, but a std::bad_alloc is thrown. * On allocation error, the returned pointer is undefined, but a std::bad_alloc is thrown.
* The default constructor of T is called. * The default constructor of T is called.
*/ */
template<typename T> EIGEN_DEVICE_FUNC inline T* aligned_new(size_t size) template<typename T> EIGEN_DEVICE_FUNC inline T* aligned_new(std::size_t size)
{ {
check_size_for_overflow<T>(size); check_size_for_overflow<T>(size);
T *result = reinterpret_cast<T*>(aligned_malloc(sizeof(T)*size)); T *result = reinterpret_cast<T*>(aligned_malloc(sizeof(T)*size));
@ -309,7 +309,7 @@ template<typename T> EIGEN_DEVICE_FUNC inline T* aligned_new(size_t size)
return result; return result;
} }
template<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned_new(size_t size) template<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned_new(std::size_t size)
{ {
check_size_for_overflow<T>(size); check_size_for_overflow<T>(size);
T *result = reinterpret_cast<T*>(conditional_aligned_malloc<Align>(sizeof(T)*size)); T *result = reinterpret_cast<T*>(conditional_aligned_malloc<Align>(sizeof(T)*size));
@ -328,7 +328,7 @@ template<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned
/** \internal Deletes objects constructed with aligned_new /** \internal Deletes objects constructed with aligned_new
* The \a size parameters tells on how many objects to call the destructor of T. * The \a size parameters tells on how many objects to call the destructor of T.
*/ */
template<typename T> EIGEN_DEVICE_FUNC inline void aligned_delete(T *ptr, size_t size) template<typename T> EIGEN_DEVICE_FUNC inline void aligned_delete(T *ptr, std::size_t size)
{ {
destruct_elements_of_array<T>(ptr, size); destruct_elements_of_array<T>(ptr, size);
aligned_free(ptr); aligned_free(ptr);
@ -337,13 +337,13 @@ template<typename T> EIGEN_DEVICE_FUNC inline void aligned_delete(T *ptr, size_t
/** \internal Deletes objects constructed with conditional_aligned_new /** \internal Deletes objects constructed with conditional_aligned_new
* The \a size parameters tells on how many objects to call the destructor of T. * The \a size parameters tells on how many objects to call the destructor of T.
*/ */
template<typename T, bool Align> EIGEN_DEVICE_FUNC inline void conditional_aligned_delete(T *ptr, size_t size) template<typename T, bool Align> EIGEN_DEVICE_FUNC inline void conditional_aligned_delete(T *ptr, std::size_t size)
{ {
destruct_elements_of_array<T>(ptr, size); destruct_elements_of_array<T>(ptr, size);
conditional_aligned_free<Align>(ptr); conditional_aligned_free<Align>(ptr);
} }
template<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned_realloc_new(T* pts, size_t new_size, size_t old_size) template<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned_realloc_new(T* pts, std::size_t new_size, std::size_t old_size)
{ {
check_size_for_overflow<T>(new_size); check_size_for_overflow<T>(new_size);
check_size_for_overflow<T>(old_size); check_size_for_overflow<T>(old_size);
@ -366,7 +366,7 @@ template<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned
} }
template<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned_new_auto(size_t size) template<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned_new_auto(std::size_t size)
{ {
if(size==0) if(size==0)
return 0; // short-cut. Also fixes Bug 884 return 0; // short-cut. Also fixes Bug 884
@ -387,7 +387,7 @@ template<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned
return result; return result;
} }
template<typename T, bool Align> inline T* conditional_aligned_realloc_new_auto(T* pts, size_t new_size, size_t old_size) template<typename T, bool Align> inline T* conditional_aligned_realloc_new_auto(T* pts, std::size_t new_size, std::size_t old_size)
{ {
check_size_for_overflow<T>(new_size); check_size_for_overflow<T>(new_size);
check_size_for_overflow<T>(old_size); check_size_for_overflow<T>(old_size);
@ -409,7 +409,7 @@ template<typename T, bool Align> inline T* conditional_aligned_realloc_new_auto(
return result; return result;
} }
template<typename T, bool Align> EIGEN_DEVICE_FUNC inline void conditional_aligned_delete_auto(T *ptr, size_t size) template<typename T, bool Align> EIGEN_DEVICE_FUNC inline void conditional_aligned_delete_auto(T *ptr, std::size_t size)
{ {
if(NumTraits<T>::RequireInitialization) if(NumTraits<T>::RequireInitialization)
destruct_elements_of_array<T>(ptr, size); destruct_elements_of_array<T>(ptr, size);
@ -561,7 +561,7 @@ template<typename T> class aligned_stack_memory_handler : noncopyable
* In this case, the buffer elements will also be destructed when this handler will be destructed. * In this case, the buffer elements will also be destructed when this handler will be destructed.
* Finally, if \a dealloc is true, then the pointer \a ptr is freed. * Finally, if \a dealloc is true, then the pointer \a ptr is freed.
**/ **/
aligned_stack_memory_handler(T* ptr, size_t size, bool dealloc) aligned_stack_memory_handler(T* ptr, std::size_t size, bool dealloc)
: m_ptr(ptr), m_size(size), m_deallocate(dealloc) : m_ptr(ptr), m_size(size), m_deallocate(dealloc)
{ {
if(NumTraits<T>::RequireInitialization && m_ptr) if(NumTraits<T>::RequireInitialization && m_ptr)
@ -576,7 +576,7 @@ template<typename T> class aligned_stack_memory_handler : noncopyable
} }
protected: protected:
T* m_ptr; T* m_ptr;
size_t m_size; std::size_t m_size;
bool m_deallocate; bool m_deallocate;
}; };
@ -655,15 +655,15 @@ template<typename T> void swap(scoped_array<T> &a,scoped_array<T> &b)
#if EIGEN_MAX_ALIGN_BYTES!=0 #if EIGEN_MAX_ALIGN_BYTES!=0
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
void* operator new(size_t size, const std::nothrow_t&) EIGEN_NO_THROW { \ void* operator new(std::size_t size, const std::nothrow_t&) EIGEN_NO_THROW { \
EIGEN_TRY { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \ EIGEN_TRY { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \
EIGEN_CATCH (...) { return 0; } \ EIGEN_CATCH (...) { return 0; } \
} }
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \ #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \
void *operator new(size_t size) { \ void *operator new(std::size_t size) { \
return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \ return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \
} \ } \
void *operator new[](size_t size) { \ void *operator new[](std::size_t size) { \
return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \ return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \
} \ } \
void operator delete(void * ptr) EIGEN_NO_THROW { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \ void operator delete(void * ptr) EIGEN_NO_THROW { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
@ -673,8 +673,8 @@ template<typename T> void swap(scoped_array<T> &a,scoped_array<T> &b)
/* in-place new and delete. since (at least afaik) there is no actual */ \ /* in-place new and delete. since (at least afaik) there is no actual */ \
/* memory allocated we can safely let the default implementation handle */ \ /* memory allocated we can safely let the default implementation handle */ \
/* this particular case. */ \ /* this particular case. */ \
static void *operator new(size_t size, void *ptr) { return ::operator new(size,ptr); } \ static void *operator new(std::size_t size, void *ptr) { return ::operator new(size,ptr); } \
static void *operator new[](size_t size, void* ptr) { return ::operator new[](size,ptr); } \ static void *operator new[](std::size_t size, void* ptr) { return ::operator new[](size,ptr); } \
void operator delete(void * memory, void *ptr) EIGEN_NO_THROW { return ::operator delete(memory,ptr); } \ void operator delete(void * memory, void *ptr) EIGEN_NO_THROW { return ::operator delete(memory,ptr); } \
void operator delete[](void * memory, void *ptr) EIGEN_NO_THROW { return ::operator delete[](memory,ptr); } \ void operator delete[](void * memory, void *ptr) EIGEN_NO_THROW { return ::operator delete[](memory,ptr); } \
/* nothrow-new (returns zero instead of std::bad_alloc) */ \ /* nothrow-new (returns zero instead of std::bad_alloc) */ \
@ -713,7 +713,7 @@ template<class T>
class aligned_allocator : public std::allocator<T> class aligned_allocator : public std::allocator<T>
{ {
public: public:
typedef size_t size_type; typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
typedef T* pointer; typedef T* pointer;
typedef const T* const_pointer; typedef const T* const_pointer;

View File

@ -1301,11 +1301,11 @@ EIGEN_DONT_INLINE typename SparseMatrix<_Scalar,_Options,_StorageIndex>::Scalar&
// starts with: [ 0 0 0 0 0 1 ...] and we are inserted in, e.g., // starts with: [ 0 0 0 0 0 1 ...] and we are inserted in, e.g.,
// the 2nd inner vector... // the 2nd inner vector...
bool isLastVec = (!(previousOuter==-1 && m_data.size()!=0)) bool isLastVec = (!(previousOuter==-1 && m_data.size()!=0))
&& (size_t(m_outerIndex[outer+1]) == m_data.size()); && (std::size_t(m_outerIndex[outer+1]) == m_data.size());
size_t startId = m_outerIndex[outer]; std::size_t startId = m_outerIndex[outer];
// FIXME let's make sure sizeof(long int) == sizeof(size_t) // FIXME let's make sure sizeof(long int) == sizeof(std::size_t)
size_t p = m_outerIndex[outer+1]; std::size_t p = m_outerIndex[outer+1];
++m_outerIndex[outer+1]; ++m_outerIndex[outer+1];
double reallocRatio = 1; double reallocRatio = 1;

View File

@ -22,13 +22,13 @@ namespace Eigen {
class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR<T> class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR<T>
{ {
public: public:
typedef size_t size_type; typedef std::size_t size_type;
typedef ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
typedef T* pointer; typedef T* pointer;
typedef const T* const_pointer; typedef const T* const_pointer;
typedef T& reference; typedef T& reference;
typedef const T& const_reference; typedef const T& const_reference;
typedef T value_type; typedef T value_type;
template<class U> template<class U>
struct rebind struct rebind