delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/18/07:12:48

From: Randy Merkel <Randy-Merkel AT postoffice DOT worldnet DOT att DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: PLEASE HELP! Can't compile <string>
Date: Sat, 18 Jan 1997 00:27:20 -0800
Organization: Clover Software
Lines: 85
Message-ID: <32E08967.14F9@postoffice.worldnet.att.net>
Reply-To: rmerkel AT acm DOT org
NNTP-Posting-Host: 207.147.204.28
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Howdy One and All;

I've posted this message before but I didn't receive any replys. Note
however I'm a newgroup newbe (read: dummy). So forgive me if someone has
replied and I didn't notice!

I'm getting "ambiguous template instantiation" errors for basic_string's
synthisied operators, i.e., !=, >, <=, and so on.  My program follows
(From the "STL Tutorial and Reference Guide, Musser and Saini":

// Demonstrating an STL map.

#include <cstdlib>
#ifdef	__GNUC__
#	include <iostream.h>
#else
#	include <iostream>
#endif
#include <map>
#include <string>

int main()
{
    map<string, long, less<string> > directory;
    directory["Bogart"] = 1234567;
    directory["Bacall"] = 9876543;
    directory["Cagney"] = 3459876;
    // etc.

    // Read some names and look up their numbers.
    string name;
    while (cin >> name) 
        if (directory.find(name) != directory.end()) 
            cout << "The phone number for " << name
                << " is " << directory[name] << "\n";
        else
            cout << "Sorry, no listing for " << name << "\n";

    return EXIT_SUCCESS;
}

I'm using the following command line:

D:\Randys\Programing\STL> gxx -O -fhandle-exceptions *.cpp

And Here are the error messages:

In file included from d:/djgpp/lang/cxx/std/bastring.h:571,
                 from d:/djgpp/lang/cxx/std/string.h:6,
                 from d:/djgpp/lang/cxx/string:5,
                 from ex02-02.cpp:10:
d:/djgpp/lang/cxx/std/sinst.h:60: ambiguous template instantiation for
`operator !=(const char *, const
basic_string<char,string_char_traits<char> > &)' requested
d:/djgpp/lang/cxx/std/sinst.h:60: ambiguous template instantiation for
`operator !=(const basic_string<char,string_char_traits<char> > &, const
char *)' requested
d:/djgpp/lang/cxx/std/sinst.h:62: ambiguous template instantiation for
`operator >(const char *, const
basic_string<char,string_char_traits<char> > &)' requested
d:/djgpp/lang/cxx/std/sinst.h:62: ambiguous template instantiation for
`operator >(const basic_string<char,string_char_traits<char> > &, const
char *)' requested
d:/djgpp/lang/cxx/std/sinst.h:63: ambiguous template instantiation for
`operator <=(const char *, const
basic_string<char,string_char_traits<char> > &)' requested
d:/djgpp/lang/cxx/std/sinst.h:63: ambiguous template instantiation for
`operator <=(const basic_string<char,string_char_traits<char> > &, const
char *)' requested
d:/djgpp/lang/cxx/std/sinst.h:64: ambiguous template instantiation for
`operator >=(const char *, const
basic_string<char,string_char_traits<char> > &)' requested
d:/djgpp/lang/cxx/std/sinst.h:64: ambiguous template instantiation for
`operator >=(const basic_string<char,string_char_traits<char> > &, const
char *)' requested

Thanks in advance for the help!


-- Randy

====================================================================
Randy Merkel o-
NAR #65722 SR
rmerkel AT ACM DOT org

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019