F
fimarn
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:
class shm_objptr_list : public std::list < void*, SharedMemAlloc<void
*> >
{
.....
bool remove(void *data) {
iterator l_iter = find(data);
if(l_iter == end()) return false;
erase(l_iter); // <=== Compiler flags this line
return true;
}
========================
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(); }
};
==============================================
The error looks like this:
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/stl_list.h:
In member function typename _Alloc::rebind<_Tp >:ther
std::_List_base<_Tp,
_Alloc>::_M_get_Tp_allocator() const [with _Tp = void*, _Alloc =
SharedMemAlloc<std::_List_node<void* > >]:
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/stl_list.h:1149:
instantiated from void std::list<_Tp, _
Alloc>::_M_erase(std::_List_iterator<_Tp>) [with _Tp = void*, _Alloc =
SharedMemAlloc<std::_List_node<void*> >]
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/list.tcc:98:
instantiated from 'typename std::list<_Tp, _ Alloc>::iterator
std::list<_Tp,
_Alloc>::erase(std::_List_iterator<_Tp>) [with _Tp = void*, _Alloc =
SharedMemAlloc<std::_List_node <void*> >]'
shmcont.h:71: instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/stl_list.h:327:
============================================================
I noticed that in a new stl_list.h we have the following:
-----------------------------------------------------------
typedef typename _Alloc::template rebind<_Tp>:ther
_Tp_alloc_type;
Tp_alloc_type
_M_get_Tp_allocator() const
allocator_type
get_allocator() const
{ return _M_get_Tp_allocator(); }
----------------------------------------------------------------
while in the old one:
----------------------------------------------------------------
typedef typename _Alloc::template rebind<_List_node<_Tp> >:ther
_Node_Alloc_type;
allocator_type
get_allocator() const
{ return allocator_type(*static_cast<const
_Node_Alloc_type*>(&this->_M_impl)); }
-----------------------------------------------------------------
I do not know how to change my declaration of the allocator to allow
conversion required by the new header file.
-- FR
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:
class shm_objptr_list : public std::list < void*, SharedMemAlloc<void
*> >
{
.....
bool remove(void *data) {
iterator l_iter = find(data);
if(l_iter == end()) return false;
erase(l_iter); // <=== Compiler flags this line
return true;
}
========================
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(); }
};
==============================================
The error looks like this:
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/stl_list.h:
In member function typename _Alloc::rebind<_Tp >:ther
std::_List_base<_Tp,
_Alloc>::_M_get_Tp_allocator() const [with _Tp = void*, _Alloc =
SharedMemAlloc<std::_List_node<void* > >]:
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/stl_list.h:1149:
instantiated from void std::list<_Tp, _
Alloc>::_M_erase(std::_List_iterator<_Tp>) [with _Tp = void*, _Alloc =
SharedMemAlloc<std::_List_node<void*> >]
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/list.tcc:98:
instantiated from 'typename std::list<_Tp, _ Alloc>::iterator
std::list<_Tp,
_Alloc>::erase(std::_List_iterator<_Tp>) [with _Tp = void*, _Alloc =
SharedMemAlloc<std::_List_node <void*> >]'
shmcont.h:71: instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/stl_list.h:327:
non-scalar type 'sharedMemAlloc<void*>' requestederror: conversion from 'const SharedMemAllo c said:' to
============================================================
I noticed that in a new stl_list.h we have the following:
-----------------------------------------------------------
_Node_alloc_type;typedef typename _Alloc::template rebind said::ther
typedef typename _Alloc::template rebind<_Tp>:ther
_Tp_alloc_type;
Tp_alloc_type
_M_get_Tp_allocator() const
{ return *static_cast said:_M_impl); }
allocator_type
get_allocator() const
{ return _M_get_Tp_allocator(); }
----------------------------------------------------------------
while in the old one:
----------------------------------------------------------------
typedef typename _Alloc::template rebind<_List_node<_Tp> >:ther
_Node_Alloc_type;
allocator_type
get_allocator() const
{ return allocator_type(*static_cast<const
_Node_Alloc_type*>(&this->_M_impl)); }
-----------------------------------------------------------------
I do not know how to change my declaration of the allocator to allow
conversion required by the new header file.
-- FR