views:

44

answers:

1

Had this:

rtable.insert ( pair<string,string>(destination,nhop) ); // route insertion
return 0;

Changed it to this:

if (rtable.insert ( pair<string,string>(destination,nhop)) == 0){
    return 0;
}

First one compiles fine. Second one gives me a make error 1. I can go back and forth all day -- I can't see any issues. Any ideas?

+3  A: 

That overload of std::map::insert() returns a std::pair<iterator, bool>. You can't compare that against zero.

That bool element tells you whether a new element was inserted; if you want to compare against that you can simply use:

if (rtable.insert(pair<string,string>(destination,nhop)).second)
    return 0
James McNellis
I read the documentation wrong for the return of the command. Should have looked at it more carefully. Thanks.
BSchlinker