M
Mark P
In my code I use something like:
typedef std::list<Edge*,g_mm_Alloc<Edge*> > EdgeList;
and then instantiate some EdgeList objects. Here Edge is a previously
defined class and g_mm_Alloc<T> is a previously defined custom STL
allocator template.
Trying to compile on a Sun system I get the following error:
"/opt/SUNWspro/prod/include/CC/Cstd/./memory", line 488: Error: Using
static_cast to convert from newScan::Edge** to std::list<newScan::Edge*,
g_mm_Alloc<newScan::Edge*>>::__list_node_buffer* not allowed.
"/opt/SUNWspro/prod/include/CC/Cstd/./list", line 132: Where: While
instantiating "std::allocator_interface<g_mm_Alloc<newScan::Edge*>,
std::list<newScan::Edge*,
g_mm_Alloc<newScan::Edge*>>::__list_node_buffer>::allocate(unsigned,
std::list<newScan::Edge*,
g_mm_Alloc<newScan::Edge*>>::__list_node_buffer*)".
"/opt/SUNWspro/prod/include/CC/Cstd/./list", line 132: Where:
Instantiated from non-template code.
Looking for line 488 of ".../memory" I see:
//
// allocator_interface provides all types and typed functions. Memory
// allocated as raw bytes using the class provided by the Allocator
// template parameter. allocator_interface casts appropriately.
//
// Multiple allocator_interface objects can attach to a single
// allocator, thus allowing one allocator to allocate all storage
// for a container, regardless of how many types are involved.
//
// The only real restriction is that pointer and reference are
// hard coded as T* and T&. Partial specialization would
// get around this.
//
template <class Allocator,class T>
class allocator_interface
{
public:
typedef Allocator allocator_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T value_type;
typedef _TYPENAME _RWSTD_ALLOC_SIZE_TYPE size_type;
typedef _TYPENAME _RWSTD_ALLOC_DIFF_TYPE difference_type;
typedef void* void_pointer;
typedef const void* const_void_pointer;
protected:
allocator_type alloc_;
public:
allocator_interface() _RWSTD_THROW_SPEC_NULL { ; }
allocator_interface(const Allocator& a) _RWSTD_THROW_SPEC_NULL
: alloc_(a) { ; }
pointer address (T& x)
{
return _RWSTD_STATIC_CAST(pointer,&x);
}
size_type max_size () const
{
return alloc_.max_size(sizeof(T));
}
pointer allocate(size_type n, pointer p = 0)
{
return _RWSTD_STATIC_CAST(pointer,alloc_.allocate(n*sizeof(T),p));
// LINE 488 IS IMMEDIATELY ABOVE
}
void deallocate(pointer p, size_type n)
{
alloc_.deallocate(p,n*sizeof(T));
}
inline void construct(pointer p, const T& val);
inline void destroy(T* p);
};
I have no idea what to make of this. It looks like it's trying to cast
a list node to a T*, where it ought to be using some sort of rebind
mechanism. Any help or guidance would be greatly appreciated.
Thanks,
Mark
typedef std::list<Edge*,g_mm_Alloc<Edge*> > EdgeList;
and then instantiate some EdgeList objects. Here Edge is a previously
defined class and g_mm_Alloc<T> is a previously defined custom STL
allocator template.
Trying to compile on a Sun system I get the following error:
"/opt/SUNWspro/prod/include/CC/Cstd/./memory", line 488: Error: Using
static_cast to convert from newScan::Edge** to std::list<newScan::Edge*,
g_mm_Alloc<newScan::Edge*>>::__list_node_buffer* not allowed.
"/opt/SUNWspro/prod/include/CC/Cstd/./list", line 132: Where: While
instantiating "std::allocator_interface<g_mm_Alloc<newScan::Edge*>,
std::list<newScan::Edge*,
g_mm_Alloc<newScan::Edge*>>::__list_node_buffer>::allocate(unsigned,
std::list<newScan::Edge*,
g_mm_Alloc<newScan::Edge*>>::__list_node_buffer*)".
"/opt/SUNWspro/prod/include/CC/Cstd/./list", line 132: Where:
Instantiated from non-template code.
Looking for line 488 of ".../memory" I see:
//
// allocator_interface provides all types and typed functions. Memory
// allocated as raw bytes using the class provided by the Allocator
// template parameter. allocator_interface casts appropriately.
//
// Multiple allocator_interface objects can attach to a single
// allocator, thus allowing one allocator to allocate all storage
// for a container, regardless of how many types are involved.
//
// The only real restriction is that pointer and reference are
// hard coded as T* and T&. Partial specialization would
// get around this.
//
template <class Allocator,class T>
class allocator_interface
{
public:
typedef Allocator allocator_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T value_type;
typedef _TYPENAME _RWSTD_ALLOC_SIZE_TYPE size_type;
typedef _TYPENAME _RWSTD_ALLOC_DIFF_TYPE difference_type;
typedef void* void_pointer;
typedef const void* const_void_pointer;
protected:
allocator_type alloc_;
public:
allocator_interface() _RWSTD_THROW_SPEC_NULL { ; }
allocator_interface(const Allocator& a) _RWSTD_THROW_SPEC_NULL
: alloc_(a) { ; }
pointer address (T& x)
{
return _RWSTD_STATIC_CAST(pointer,&x);
}
size_type max_size () const
{
return alloc_.max_size(sizeof(T));
}
pointer allocate(size_type n, pointer p = 0)
{
return _RWSTD_STATIC_CAST(pointer,alloc_.allocate(n*sizeof(T),p));
// LINE 488 IS IMMEDIATELY ABOVE
}
void deallocate(pointer p, size_type n)
{
alloc_.deallocate(p,n*sizeof(T));
}
inline void construct(pointer p, const T& val);
inline void destroy(T* p);
};
I have no idea what to make of this. It looks like it's trying to cast
a list node to a T*, where it ought to be using some sort of rebind
mechanism. Any help or guidance would be greatly appreciated.
Thanks,
Mark