I have created the following comparator to test the map:
struct comparator{
bool operatior() (int a,int b){
return 1;
}
}
then the following algorthim:
int main(){
// imports string to currentString
...
std::map<int,char> default_map;
std::map<int,char,comparator> test_map;
while(i < stringSize){
if(currentString[i] == '(' || currentString[i] == ')'){
default_map[i]=currentString[i];
test_map[i]=currentString[i];
}
}
auto currentIterator = default_map.begin();
while(currentIterator != default_map.end()){
printf("%d %c\n",currentIterator->first,currentIterator->second);
}
auto currentIterator = test_map.begin();
while(currentIterator != test_map.end()){
printf("%d %c\n",currentIterator->first,currentIterator->second);
}
return 0;
}
Here the default_map prints all of the parenthesis, while the test_map with the custom comparitor only prints the first two parenthesis.
Is this a bug in the map code? I originally wanted to have class as the key with a custom comparator, but it isn't even working with a custom int key.
My make file does use the -std=c++1y tag so maybe that is effecting it? I don't know what to do. I am considering to see if the SGI map will work better than the std one.