map issue using the old/default std

Please, help with the following simple compilation

***********************************

// print_routines.cpp

#include <map>

#include <string>

int main()

{

std::map<const std::string, bool> fred;

return 0;

}

********************************

-bash-3.00$ CC print_routines.cpp

"/opt/SUNWspro/prod/include/CC/Cstd/./map", line 251: Error: Multiple declaration for std::map<const std::string, bool, std::less><const std::string>, std::allocator<std::pair><const std::string, bool>>>::insert(const std::pair<const std::string, bool>&).

"print_routines.cpp", line 6: Where: While specializing "std::map<const std::string, bool, std::less><const std::string>, std::allocator<std::pair><const std::string, bool>>>".

"print_routines.cpp", line 6: Where: Specialized in non-template code.

1 Error(s) detected.

Thank you very much.

stephen

[1024 byte] By [stephen_ba] at [2007-11-26 13:36:35]
# 1
forgot to mentionthe above compiles and runs OK with stlport4, but occi will be needed, so the default lib has to stay.
stephen_ba at 2007-7-7 22:22:12 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
I got it:map<string, bool> mymap;works.
stephen_ba at 2007-7-7 22:22:12 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

the following excerpt is wrong and exactly the opposite is true: you do not need const before the key type.

http://developers.sun.com/sunstudio/documentation/ss11/mr/READMEs/c++_faq.html# LibComp2

********************************************

What are the consequences of the missing standard library functionality?

Some code that is valid according to the C++ standard will not compile.

The most common example is creating maps where the first element of the pair could be const but isn't declared that way. The member constructor template would convert pair<T, U> to pair<const T, U> implicitly when needed. Because that constructor is missing, you get compilation errors instead.

Since you are not allowed to change the first member of a pair in a map anyway, the simplest fix is to use an explicit const when creating the pair type. For example, instead of pair<int, T> use pair<const int, T>; instead of map<int, T> use map<const int, T>.

****************************************************

stephen_ba at 2007-7-7 22:22:12 > top of Java-index,Development Tools,Solaris and Linux Development Tools...