Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > allocator requirements

Reply
Thread Tools

allocator requirements

 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-09-2004
Jonathan Turkanis wrote:
> "John Harrison" <(E-Mail Removed)> wrote in message
> newspsav3hke1212331@andronicus...
>
>>On Fri, 9 Jul 2004 15:21:25 -0600, Jonathan Turkanis
>><(E-Mail Removed)> wrote:
>>
>>
>>>"John Harrison" <(E-Mail Removed)> wrote in message
>>>newspsav1xfa5212331@andronicus...

> [...]
>>>>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;

>
>
> That's funny. My copy has
>
> vector<int, MyAlloc<int> > v;
> map<int,float,less<int>,MyAlloc<std:air<const int, float> > > m;
> ...


<Butting in...>

So does mine, but it's the 7th printing (what's yours?) so, either
before they printed something differently or after...

V
 
Reply With Quote
 
 
 
 
Jonathan Turkanis
Guest
Posts: n/a
 
      07-09-2004

"Victor Bazarov" <(E-Mail Removed)> wrote in message
news:uvEHc.1987$(E-Mail Removed)...
> Jonathan Turkanis wrote:
> > "John Harrison" <(E-Mail Removed)> wrote in message
> > newspsav3hke1212331@andronicus...


> >>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;

> >
> >
> > That's funny. My copy has
> >
> > vector<int, MyAlloc<int> > v;
> > map<int,float,less<int>,MyAlloc<std:air<const int, float> > >

m;
> > ...

>
> <Butting in...>
>
> So does mine, but it's the 7th printing (what's yours?) so, either
> before they printed something differently or after...


Mine is the 10th. I wonder if Josuttis changed it because he decided
it was an error or because he thought it was debatable or an
unnecessary distraction.

I'm a bit suprised that the requirement that the value_type's match is
stated clearly for basic_string (21.3/1) but only in an almost
parenthetical way for containers generally (23.1/, AFAICT.

Jonathan


 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      07-10-2004
>>
>> 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.

>
> I think this approach gives meaning to an otherwise ill formed program,
> hence it's a conforming implementation.
>


Yes, thinking about it I agree.

john
 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      07-10-2004
On Fri, 9 Jul 2004 16:13:19 -0600, Jonathan Turkanis
<(E-Mail Removed)> wrote:

>>

> Mine is the 10th. I wonder if Josuttis changed it because he decided
> it was an error or because he thought it was debatable or an
> unnecessary distraction.
>


Mine's the third, the change is listed in the errata on his website.

john
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Idea for custom thread-safe STL allocator? Brian Genisio C++ 12 01-15-2004 03:41 PM
allocator traits? Alexander Stippler C++ 4 09-03-2003 05:10 PM
How to write an allocator for the STL List in VC++ 6.0 =?ISO-8859-1?Q?Ralf_Schneewei=DF?= C++ 2 08-20-2003 11:48 PM
allocator size_type Fraser Ross C++ 1 07-31-2003 10:39 PM
[ANN] Thread-aware STL-compatible memory allocator Dan C++ 0 07-29-2003 08:06 PM



Advertisments