#include <iostream>
#include <map>
#include <string>

int main()
{
    std::map< int, std::string > map { {  1, "one" }, { 3,"three" }, { 5,"five" },
                                       { 7, "seven" }, { 9, "nine" }, { 11, "eleven" } } ;

    std::map<int,std::string>::key_type two = 2 ;
    std::map<int,std::string>::key_type ten = 10 ;

    // iterate from two to ten inclusive
    // see: http://e...content-available-to-author-only...e.com/w/cpp/container/map/upper_bound
    // see: http://e...content-available-to-author-only...e.com/w/cpp/container/map/lower_bound
    auto end = map.upper_bound(ten) ;
    for( auto iter = map.lower_bound(two) ; iter != end ; ++iter )
        std::cout << '{' << iter->first << ',' << iter->second << "} " ;
    std::cout << '\n' ;

    // iterate from two up to not including ten
    end = map.lower_bound(ten) ;
    for( auto iter = map.lower_bound(two) ; iter != end ; ++iter )
        std::cout << '{' << iter->first << ',' << iter->second << "} " ;
    std::cout << '\n' ;

    map[2] = "two" ;
    map[10] = "ten" ;

    // iterate from two to ten inclusive
    end = map.upper_bound(ten) ;
    for( auto iter = map.lower_bound(two) ; iter != end ; ++iter )
        std::cout << '{' << iter->first << ',' << iter->second << "} " ;
    std::cout << '\n' ;

    // iterate from two up to not including ten
    end = map.lower_bound(ten) ;
    for( auto iter = map.lower_bound(two) ; iter != end ; ++iter )
        std::cout << '{' << iter->first << ',' << iter->second << "} " ;
    std::cout << '\n' ;
}
