Wednesday, May 16, 2012

STL nested containers dereferencing error

I'm pretty rusty in my C++ and what little STL knowledge I once had. I'm particularly struggling to read the voluminous error messages generated.


typedef map<string,int>layerType;
typedef vector<layerType> aggregateLayersType;

What's wrong with:

bool LayerManager::use_layers(aggregateLayersType& layers)
int layerVal = layers[0]["ts"];

The error is:

> No viable overloaded operator[] for type
> 'std::__debug::map<std::basic_string<char, std::char_traits<char>,
> std::allocator<char> >, int, std::less<std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > >,
> std::allocator<std::pair<const std::basic_string<char,
> std::char_traits<char>, std::allocator<char> >, int> > >'

I'm sure it's going to be something simple once someone points out the obvious.

No comments:

Post a Comment