Article View: comp.std.c++
Article #1839STL map and pair classes
From: Michael Rice
Date: Thu, 24 Aug 1995 20:26
Date: Thu, 24 Aug 1995 20:26
44 lines
1955 bytes
1955 bytes
Distribution:
I can't seem to get the map class to compile in the July 7, 1995
version of STL using xlC. This compiler hasn't had any other trouble
compiling it yet.
For the following:
int main ()
{
typedef map<char, int, less<char> > maptype;
maptype m;
return 0;
}
The error message is this:
"tree.h", line 56.1: 1540-222: (S) "rb_tree<char,pair<const char,int>,select1st<pair<const char,int>,char>,less<char> >::rb_tree_node" needs a constructor because class member "value_field" needs a constructor initializer.
"mm.C", line 14.1: 1540-207: (I) The previous message applies to the definition of template "map<char,int,less<char> >".
The error seems reasonable to me, and goes away if pair has a default
constructor. Why doesn't pair have a default constructor anyway? Some
functions return pairs, so people would probably want to write code
like this:
void func() {
pair<type1, type2> pp; // illegal without a def. constructor?
// do something
pp = s.insert(x);
}
Also according to the draft standard, who is wrong here, the compiler or
STL? And this stuff is supposed to work with xlC isn't it or it this one
of those "corner cases"?
--
Mike Rice Absoft Corporation
mpr@absoft.com (810) 853-0050
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<MATT.95Aug24132601@physics2.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!128.32.155.1!mattShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt From: "Michael Rice" <mpr@absoft.com> Newsgroups: comp.std.c++ Subject: STL map and pair classes Date: 24 Aug 1995 20:26:00 GMT Organization: <none> Approved: matt@physics2.Berkeley.EDU (Matt Austern) Message-ID: <MATT.95Aug24132601@physics2.Berkeley.EDU> Reply-To: mpr@absoft.com NNTP-Posting-Host: physics2.berkeley.edu