allocator question
- From: "Mycroft Holmes" <m.holmes@xxxxxxxxx>
- Date: Thu, 2 Jun 2005 14:44:45 +0200
Hi to all,
when passing an allocator to SEVERAL containers at the same time, can we
rely on the "rebind" mechanism assuming that each container is able to
select its own allocator?
for example: is the following ok?
template <class T, class allocator_t>
class MyContainer
{
std::vector<T, allocator_t> v_;
std::map<T, int, std::less<T>, allocator_t> m_;
};
or should we be verbose and deduce the correct allocators out of the
sub-containers:
template <class T, class allocator_t>
class MyContainer
{
typedef typename allocator_t::template rebind<T>::other rebind1_t;
std::vector<double, rebind1_t> v_;
typedef typename allocator_t::template rebind< std::pair<const T,
int>::other rebind2_t;
// etc...
};
of course version #1 and version #2 declare a class whose members have
different types (say, m_ is map<T,int, ... allocator<T> > and map<T,int, ...
allocator< std::pair<...> > >), but apart from that, are they "functionally"
equivalent?
.
- Follow-Ups:
- Re: allocator question
- From: Doug Harrison [MVP]
- Re: allocator question
- Prev by Date: Re: Console App - howto determine if an app is a console app
- Next by Date: Capturing the save click events in Microsoft word.
- Previous by thread: Files in current directory
- Next by thread: Re: allocator question
- Index(es):
Relevant Pages
|