Re: allocator requirements
From: John Harrison (john_andronicus_at_hotmail.com)
Date: 07/09/04
- Next message: Nicholas Salerno: "Re: Is there anything in C++ akin to Java's class Object?"
- Previous message: Howard: "Re: Visit Website??"
- In reply to: Jonathan Turkanis: "Re: allocator requirements"
- Next in thread: Jonathan Turkanis: "Re: allocator requirements"
- Reply: Jonathan Turkanis: "Re: allocator requirements"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 09 Jul 2004 22:33:10 +0100
On Fri, 9 Jul 2004 15:21:25 -0600, Jonathan Turkanis
<technews@kangaroologic.com> wrote:
>
> "John Harrison" <john_andronicus@hotmail.com> wrote in message
> news:opsav1xfa5212331@andronicus...
>> On Fri, 09 Jul 2004 20:47:16 GMT, P.J. Plauger <pjp@dinkumware.com>
> wrote:
>>
>> > "John Harrison" <john_andronicus@hotmail.com> wrote in message
>> > news:opsavy7sdb212331@andronicus...
>> >
>> >> If you specify an allocator in an STL container is it a
> requirement that
>> >> the allocator allocates object of the right type,
>> >
>> > Yes, according to the C++ Standard.
>> >
>> >> or can you
> assume that
>> >> the container will rebind the allocator to the correct type?
>> >
>> > Yes, according to widespread practice.
>> >
>> > P.J. Plauger
>> > Dinkumware, Ltd.
>> > http://www.dinkumware.com
>> >
>>
>> Yes it seems so, both implementations of the STL I've checked do
> rebind
>> the allocator for vector at least. This seems to directly contradict
> the
>> requirements for allocator_type.
>
> How does this contradict the allocator requirements?
Not the allocator requirements, the requirements for allocator_type. For
instance 23.2.4 has
template <class T, class Allocator = std::allocator<T> >
class vector
{
...
typedef Allocator allocator_type;
i.e. allocator_type should be the same type as the template parameter.
>
>> I also noticed that Josuttis' book also ignores what the standard
> says,
>> see first page of chapter 15 where he happily passes the same
> allocator to
>> several containers with different value types.
>
> It looks to me like the allocators he uses all have value_types
> appropriate for the containers.
>
Well maybe I'm reading too much into this but in chpater 15 in quick
succession he gives
vector<int,SpecialAlloc> v;
map<int,float,less<int>,SpecialAlloc> m;
basic_string<char,char_traits<char>,SpecialAlloc> s;
Its not specified anywhere what SpecialAlloc is but by the quote you made
from the standard it cannot have the correct value type for all these
different containers.
john
> Jonathan
>
>
- Next message: Nicholas Salerno: "Re: Is there anything in C++ akin to Java's class Object?"
- Previous message: Howard: "Re: Visit Website??"
- In reply to: Jonathan Turkanis: "Re: allocator requirements"
- Next in thread: Jonathan Turkanis: "Re: allocator requirements"
- Reply: Jonathan Turkanis: "Re: allocator requirements"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|