Thank you for the response..
Two questions :
1) What is auto?
2) I tried to compile this on my computer and have this error :
g++ -Wall -c "map2.cpp" (in directory: /home/amadio/testc++)
In file included from /usr/include/c++/4.5/array:35:0,
from map2.cpp:5:
/usr/include/c++/4.5/bits/c++0x_warning.h:31:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
map2.cpp: In function ‘int main()’:
map2.cpp:11:14: error: ‘array’ was not declared in this scope
map2.cpp:11:29: error: wrong number of template arguments (1, should be 4)
/usr/include/c++/4.5/bits/stl_map.h:86:11: error: provided for ‘template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map’
map2.cpp:11:30: error: expected unqualified-id before ‘,’ token
map2.cpp:11:38: error: expected initializer before ‘>’ token
map2.cpp:13:15: error: expected primary-expression before ‘double’
map2.cpp:13:15: error: expected ‘;’ before ‘double’
map2.cpp:14:15: error: expected primary-expression before ‘double’
map2.cpp:14:15: error: expected ‘;’ before ‘double’
map2.cpp:16:9: error: ‘mapa’ was not declared in this scope
map2.cpp:16:14: error: ‘a’ was not declared in this scope
map2.cpp:17:14: error: ‘b’ was not declared in this scope
map2.cpp:21:13: error: ‘array’ cannot appear in a constant-expression
map2.cpp:21:28: error: wrong number of template arguments (1, should be 4)
/usr/include/c++/4.5/bits/stl_map.h:86:11: error: provided for ‘template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map’
map2.cpp:21:29: error: expected unqualified-id before ‘,’ token
map2.cpp:21:37: error: expected initializer before ‘>’ token
map2.cpp:21:56: error: ‘ii’ was not declared in this scope
Compilation failed.
You could wrap your vector of doubles in a class and provide that class with an operator<
Then it will work as a key in a map
However, I think in the case of an array of doubles this will not make a good key.
This is because operator< will have poorly defined behaviour when the the floating point values are near each other.