A
abir
I have an custom allocator implementation whose base type depends on
completeness of the type parameter T, though the nested types doesn't
depend on so.
e.g.
template<typename T>
struct is_Small
{
const static bool value = (sizeof(T) < sizeof(void*) );
};
template<typename T> struct impl1{};
template<typename T> struct impl2{};
typedef T* pointer;
...
};
struct foo; //incomplete type.
typedef my_alloc<foo>:ointer foo_ptr;
The same problem are supposed to happen for stack_alloc<T,N> also, as
usually they has std::aligned_storage as memory.
So far with std::allocator these wasn't a problem though it's allocate
function is usually
return operator new (sizeof(T) *n);
I can pull the traits in a separate class as
template<typename T>
struct alloc_traits
{
typedef. T* pointer ; ...
};
and use it as
typedef alloc_traits<foo>:ointer foo_ptr;
But then I need to change the code everywhere.
Is it possible to design my_alloc such as the nested types which are
independent can still work where rest of functionality depends on
completeness of T ?
Or even is it possible to define some lazy_typedef which don't try to
instantiate the class.
I need the pointers to be defined for incomplete type for any
allocator, as otherwise many cyclic dependency will happen.
Thanks.
abir
completeness of the type parameter T, though the nested types doesn't
depend on so.
e.g.
template<typename T>
struct is_Small
{
const static bool value = (sizeof(T) < sizeof(void*) );
};
template<typename T> struct impl1{};
template<typename T> struct impl2{};
{template said:::type
typedef T* pointer;
...
};
struct foo; //incomplete type.
typedef my_alloc<foo>:ointer foo_ptr;
The same problem are supposed to happen for stack_alloc<T,N> also, as
usually they has std::aligned_storage as memory.
So far with std::allocator these wasn't a problem though it's allocate
function is usually
return operator new (sizeof(T) *n);
I can pull the traits in a separate class as
template<typename T>
struct alloc_traits
{
typedef. T* pointer ; ...
};
and use it as
typedef alloc_traits<foo>:ointer foo_ptr;
But then I need to change the code everywhere.
Is it possible to design my_alloc such as the nested types which are
independent can still work where rest of functionality depends on
completeness of T ?
Or even is it possible to define some lazy_typedef which don't try to
instantiate the class.
I need the pointers to be defined for incomplete type for any
allocator, as otherwise many cyclic dependency will happen.
Thanks.
abir