Re: problems about aCC
On Feb 16, 8:45 am, guojianlee <guojian...@gmail.com> wrote:
I have some problem ,when compiling program in
hp 11.1
aCC: HP ANSI C++ B3910B A.03.37
,just like this "aCC test.cpp".
but when i compile it with option -AA ,every thing is OK.
source code and error info as follow.who can tell me why ,thank you
very much.
source code:
$vi test.cpp
#include <map>
#include <string>
namespace std {} using namespace std;
int main()
{
map<string,string > m;
string a("11"),b("2222");
m.insert(make_pair(a,b));}
error info:
Just a guess, but it looks from the error messages as if the
version of the library you are using isn't completely up to
date. make_pair, in your case, will return an
std::pair< std::string, std::string >. The type needed for
std::map::insert (here) is an std::pair< std::string const,
std::string >. In the standard, there's an implicit conversion
of what you have to what you need, but IIRC, it was added very,
very late in the standardization proceedure, and it's entirely
possible that older libraries don't support it.
My own practice, in such cases, is to typedef the map, and then
use something like:
m.insert( Map::value_type( a, b ) ) ;
This ensures a correct type.
You might, however, want to upgrade to a more recent version of
the library (which probably means upgrading your compiler).
(As Alf points out, you should also probably include <utility>,
to be formally correct, although as <map> uses std::pair, it's
hard to imagine it not including <utility>.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34