A
asm23
Hi, I found many tutorials that talk about this issue. All they say it
it just create another type allocator from the original type allocator.
For example:
//myallocator
template<class _Ty>
class myallocator
{
public:
template<class _Other>
struct rebind
{
typedef myallocator<_Other> other;
};
//...
}
typedef myallocator<int> mi;
typedef mi::rebind<double>:
ther md; // *1*
typedef myallocator<double> md; // *2*
So, you can see, the above two statement just has the same meaning.
My question is: Why we need a rebind member. It seems that *2* can do
the same thing.
Thank you very much.
it just create another type allocator from the original type allocator.
For example:
//myallocator
template<class _Ty>
class myallocator
{
public:
template<class _Other>
struct rebind
{
typedef myallocator<_Other> other;
};
//...
}
typedef myallocator<int> mi;
typedef mi::rebind<double>:
typedef myallocator<double> md; // *2*
So, you can see, the above two statement just has the same meaning.
My question is: Why we need a rebind member. It seems that *2* can do
the same thing.
Thank you very much.