I'm on MAC OS X 10.8.4 and have installed gcc by downloading XCode and the command line tools package. Here is my gcc:
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
I'm trying to use the new unordered_map from the tr1 namespace:
using namespace std;
#include <tr1/unordered_map>
template<class T>
class A
{
tr1::unordered_map<T, int> * mymap;
.....
// key is of type T and value is of type int
mymap->at(key) = value;
}
However, the line where I'm accessing the map element using at
is not compiling. I'm getting the following error:
error: 'class std::tr1::unordered_map<int, int, std::tr1::hash<int>, std::equal_to<int>, std::allocator<std::pair<const int, int> >, false>' has no member named 'at'
I don't quite understand this since the C++ reference does include a function called at
to access individual elements of the map. I tried to look into the header files containing the map declaration (on my system it is at /usr/include/c++/4.2.1/tr1/unordered_map
) and surprisingly enough, it does not contain a member named at
.
I understand that older compilers might not be supporting new c++11 libraries in the std
namespace, but I've been able to use some of the other new libraries from tr1
namespace. In fact, I can use other functions of unordered_map
like find
, insert
etc. Only the member at
is missing.
How can I get this compiled? Should I upgrade to a newer compiler? I don't see the new compilers available for mac os x readily. Should I build it from scratch?