allocator question (reposted here... sorry for the mistake)
- From: "Mycroft Holmes" <m.holmes@xxxxxxxxx>
- Date: Thu, 2 Jun 2005 14:45:53 +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 (reposted here... sorry for the mistake)
- From: Pete Becker
- Re: allocator question (reposted here... sorry for the mistake)
- Prev by Date: Re: ifstream bug in VS2005 Beta2 & Platform SDK
- Next by Date: Re: ifstream bug in VS2005 Beta2 & Platform SDK
- Previous by thread: ifstream bug in VS2005 Beta2 & Platform SDK
- Next by thread: Re: allocator question (reposted here... sorry for the mistake)
- Index(es):
Relevant Pages
|