std::map<int32_t, int32_t> Range; //first为lower_bound, second为upper_bound std::map<int32_t, int32_t>::const_iterator it = Range.lower_bound(target); if(it!=Range.end() && target>=it->first && target<=it->second) { return true; } else if(it!=Range.begin()) { it--; return target>=it->first && target<=it->second; } else { return false; }