Topic: STL & string


Author: tottinge@alfalfa.csci.csc.com (Tim Ottinger)
Date: 1995/04/27
Raw View
Thanks all (Fergus & Others) for the replies.

>>First off, there's no < in my version of C++ for the string class.
>You can always add your own.  It doesn't have to be a member function.
Of course, I'm doing so.  I'm not trying to be a weenie, but I was kind of
hoping it would work out of the box.  Still, I love the new string type, and
I haven't completely thrown up my hands. ;-)

>>There's a problem in pair.h where the key is made const (for a good reason),
>>but that prevents the 'new' operator from being used ("new cannot be used for
>>const or static objects").
>That one has been fixed.  You are now allowed to allocate const objects
>with new.  (That was decided at Valley Forge, Nov 1994.)
Cool.  So I can just leave the warning in, or modify the pair<> as recommended.

There's talk of "the PD version" of the <string> classes?.  I'm about to toss
the GNU version into HP C++ so I can keep going until HP releases it.  Is there
another <string> source?

BTW: Standards guys -- Nice work.  It has it's problems, but it sure isn't
     the old C I used to drive.  Ahhhh... progress!

--
Tim Ottinger
------------------------------------------------------------------------------
CSC Intelicom - Wireless Billing Systems  - Champaign IL
Opinions expressed by me may be different from CSC Intelicom's position
-- Assume nothing.
------------------------------------------------------------------------------





Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: 1995/04/26
Raw View
tottinge@alfalfa.csci.csc.com (Tim Ottinger) writes:

>It seems that there are a large number of problems in getting the new string
>type to work as a key in a map<string, string>.
>
>First off, there's no < in my version of C++ for the string class.

You can always add your own.  It doesn't have to be a member function.

>There's a problem in pair.h where the key is made const (for a good reason),
>but that prevents the 'new' operator from being used ("new cannot be used for
>const or static objects").

That one has been fixed.  You are now allowed to allocate const objects
with new.  (That was decided at Valley Forge, Nov 1994.)

--
Fergus Henderson            | Tell you what: go write a 100x100 matrix multiply
fjh@cs.mu.oz.au             | of integers in both languages and then let's talk
http://www.cs.mu.oz.au/~fjh | about speed, ok? - Tom Christiansen.





Author: tottinge@alfalfa.csci.csc.com (Tim Ottinger)
Date: 1995/04/21
Raw View
It seems that there are a large number of problems in getting the new string
type to work as a key in a map<string, string>.

First off, there's no < in my version of C++ for the string class.

There's a problem in pair.h where the key is made const (for a good reason),
but that prevents the 'new' operator from being used ("new cannot be used for
const or static objects").

Is there an effort underway to make the string and STL work together?  There's
certainly no end to the uses of an associative array which is associative on
strings. I hate to write my own special string class just to support STL,
and I hate to rewrite the map class just because of strings.

--
Tim Ottinger
------------------------------------------------------------------------------
CSC Intelicom - Wireless Billing Systems  - Champaign IL
Opinions expressed by me may be different from CSC Intelicom's position
-- Assume nothing.
------------------------------------------------------------------------------





Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1995/04/22
Raw View
tottinge@alfalfa.csci.csc.com (Tim Ottinger) writes:

>It seems that there are a large number of problems in getting the new string
>type to work as a key in a map<string, string>.   ...

>Is there an effort underway to make the string and STL work together?

The string class in the C++ draft standard has been modified to work
with STL.
--
Steve Clamage, stephen.clamage@eng.sun.com





Author: maxtal@Physics.usyd.edu.au (John Max Skaller)
Date: 1995/04/22
Raw View
In article <3n9gcb$8hs@venus.roc.csci.csc.com>,
Tim Ottinger <tottinge@alfalfa.csci.csc.com> wrote:
>It seems that there are a large number of problems in getting the new string
>type to work as a key in a map<string, string>.

 What new string type are you talking about?

>First off, there's no < in my version of C++ for the string class.

 So put one in.
>
>There's a problem in pair.h where the key is made const (for a good reason),
>but that prevents the 'new' operator from being used ("new cannot be used for
>const or static objects").

 Change the key to non-const, thats what I did.
In fact you CAN have a const type in a new expression, but this
might be considered to have been confirmed by the committee
only recently.

>Is there an effort underway to make the string and STL work together?

 The ANSI/ISO string classes (plural) will be full STL
sequences themselves.

>There's
>certainly no end to the uses of an associative array which is associative on
>strings. I hate to write my own special string class just to support STL,
>and I hate to rewrite the map class just because of strings.

 The PD STL (after modifying it to get rid of the
global comparison templates) works just fine with my string class,
I cannot understand your problem. There is as yet no
finished Standard; until then -- and until there
are conforming compilers -- you have to work up your own
approximations to both the STL requirements and string classes.

--
        JOHN (MAX) SKALLER,         INTERNET:maxtal@suphys.physics.su.oz.au
 Maxtal Pty Ltd,
        81A Glebe Point Rd, GLEBE   Mem: SA IT/9/22,SC22/WG21
        NSW 2037, AUSTRALIA     Phone: 61-2-566-2189