Re: compile time error due to changes in stl_list.h code
fimarn wrote:
I am trying to get rid of compile time error that I am getting
only in RHEL5 (not in RHEL4) apparently due to the changes in
the stl_list.h file. The error that I am getting is coming
from the following code that attempts to remove an item from
the list:
[...]
========================
The allocator is declared as :
template<class T>
class SharedMemAlloc {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T *pointer;
typedef const T *const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T value_type;
template <class _T> struct rebind {
typedef SharedMemAlloc<_T> other;
};
static pointer allocate(size_type n)
{
return (pointer)SharedMemObj::allocate(n);
}
static void deallocate(void* p, size_type n)
{
SharedMemObj::deallocate(p, n);
}
void construct(pointer p, const T&val) {new (p) T(val); }
void destroy(pointer p) {p->~T(); }
};
You're missing the conversion constructor. In the standard
allocator, it's a:
template< typename U > allocator( allocator< U > const& ) ;
but if I understand the requirements correctly, all that is
required is that:
Allocator< T > a( b ) ;
is legal, where b has a type Allocator< U >, with U different
from T. (So a conversion operator or an explicit constructor
would be legal. But I'd follow the model of the standard
allocator; I'd guess that very few, if any, implementations are
tested with anything really exotic.)
PS: I've not tried to test with this added to your allocator,
but it looks like a likely cause. And did you compile with
"-D_GLIBCXX_CONCEPT_CHECKS -D_GLIBCXX_DEBUG
-D_GLIBCXX_DEBUG_PEDANTIC"? I have no idea if this would help,
but I rather think that if you didn't get an error at the first
attempt to instantiate the template (i.e. when you use it as a
base class, in the header), the people at g++ would probably
consider this an error, and try to fix it in a future release.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34