Bug 694801 - VC11 fails to compile angle because pool_allocator<T> doesn't have operator =; r=bjacob

This commit is contained in:
Ehsan Akhgari 2011-10-19 10:17:02 -04:00
parent f7b9213184
commit aae0f7a48b
3 changed files with 68 additions and 6 deletions

View File

@ -11,6 +11,7 @@ In this order:
angle-limit-identifiers-to-250-chars.patch - see bug 675625
angle-use-xmalloc.patch - see bug 680840. Can drop this patch whenever the new preprocessor lands.
angle-mCurrentValueOffsets-size_t.patch - ANGLE bug 220 - compile fix on win64
angle-pool_allocator-assignable.patch - ANGLE r798
In addition to these patches, the Makefile.in files are ours, they're not present in upsteam ANGLE.

View File

@ -0,0 +1,55 @@
diff --git a/gfx/angle/src/compiler/PoolAlloc.h b/gfx/angle/src/compiler/PoolAlloc.h
--- a/gfx/angle/src/compiler/PoolAlloc.h
+++ b/gfx/angle/src/compiler/PoolAlloc.h
@@ -248,22 +248,28 @@ public:
template<class Other>
struct rebind {
typedef pool_allocator<Other> other;
};
pointer address(reference x) const { return &x; }
const_pointer address(const_reference x) const { return &x; }
- pool_allocator() : allocator(GlobalPoolAllocator) { }
- pool_allocator(TPoolAllocator& a) : allocator(a) { }
+ pool_allocator() : allocator(&GlobalPoolAllocator) { }
+ pool_allocator(TPoolAllocator& a) : allocator(&a) { }
pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }
+ template <class Other>
+ pool_allocator<T>& operator=(const pool_allocator<Other>& p) {
+ allocator = p.allocator;
+ return *this;
+ }
+
template<class Other>
- pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
+ pool_allocator(const pool_allocator<Other>& p) : allocator(&p.getAllocator()) { }
#if defined(__SUNPRO_CC) && !defined(_RWSTD_ALLOCATOR)
// libCStd on some platforms have a different allocate/deallocate interface.
// Caller pre-bakes sizeof(T) into 'n' which is the number of bytes to be
// allocated, not the number of elements.
void* allocate(size_type n) {
return getAllocator().allocate(n);
}
@@ -285,16 +291,16 @@ public:
void destroy(pointer p) { p->T::~T(); }
bool operator==(const pool_allocator& rhs) const { return &getAllocator() == &rhs.getAllocator(); }
bool operator!=(const pool_allocator& rhs) const { return &getAllocator() != &rhs.getAllocator(); }
size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); }
size_type max_size(int size) const { return static_cast<size_type>(-1) / size; }
- void setAllocator(TPoolAllocator* a) { allocator = *a; }
- TPoolAllocator& getAllocator() const { return allocator; }
+ void setAllocator(TPoolAllocator* a) { allocator = a; }
+ TPoolAllocator& getAllocator() const { return *allocator; }
protected:
- TPoolAllocator& allocator;
+ TPoolAllocator* allocator;
};
#endif // _POOLALLOC_INCLUDED_

View File

@ -253,12 +253,18 @@ public:
pointer address(reference x) const { return &x; }
const_pointer address(const_reference x) const { return &x; }
pool_allocator() : allocator(GlobalPoolAllocator) { }
pool_allocator(TPoolAllocator& a) : allocator(a) { }
pool_allocator() : allocator(&GlobalPoolAllocator) { }
pool_allocator(TPoolAllocator& a) : allocator(&a) { }
pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }
template <class Other>
pool_allocator<T>& operator=(const pool_allocator<Other>& p) {
allocator = p.allocator;
return *this;
}
template<class Other>
pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
pool_allocator(const pool_allocator<Other>& p) : allocator(&p.getAllocator()) { }
#if defined(__SUNPRO_CC) && !defined(_RWSTD_ALLOCATOR)
// libCStd on some platforms have a different allocate/deallocate interface.
@ -290,11 +296,11 @@ public:
size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); }
size_type max_size(int size) const { return static_cast<size_type>(-1) / size; }
void setAllocator(TPoolAllocator* a) { allocator = *a; }
TPoolAllocator& getAllocator() const { return allocator; }
void setAllocator(TPoolAllocator* a) { allocator = a; }
TPoolAllocator& getAllocator() const { return *allocator; }
protected:
TPoolAllocator& allocator;
TPoolAllocator* allocator;
};
#endif // _POOLALLOC_INCLUDED_