c ++ – The element closest to the std map when deleting values

I have the following situation: I have two std::map and I want to go through the first card one by one and find the item in the second card with the key closest to the key in the first card. Now, this simple situation is obviously addressed in another question like for example. this one, but here is where my situation deviates:
It is possible that some elements of the second card are not taken into account because the value is lower than one criterion. Thus, even if the element is the closest, it will be ignored and I must now compare two other elements to the key. Below you will find some dummy code illustrating the input data and some code that seems to give what I want, but I'm not sure that there may be a better way / cleaner to do it.

#include 
#include 
#include 

void setClosest( std::map::iterator & it, std::map::iterator &upper, std::map::iterator &lower, float key ) {
  it = fabs( upper->first - key ) < fabs( lower->first - key ) ? upper : lower;
}


int main(int, char**)
{
  std::map map1;
  std::map map2;

  map1(5000)  = 5.5;
  map1(10000) = 5.2;
  map1(12000) = 5.7;
  map1(15000) = 5.3;
  map1(20000) = 5.5;
  map1(25000) = 5.9;

  map2(10400) = 523.0;
  map2(12500) = 99.0;
  map2(15200) = 67.0;
  map2(15400) = 76.0;
  map2(20200) = 511.0;
  map2(25800) = 567.0;

  std::map::iterator it = map1.begin();
  std::map::iterator lower;
  std::map::iterator upper;
  std::map::iterator closest;

  for( ; it != map1.end(); ++it ) {
    int key     = it->first;
    float value = it->second;

    lower = map2.lower_bound(key);
    upper = ( lower == map2.begin() ? lower : lower-- );

    setClosest( closest, upper, lower, key);

    std::cout << key << ' ' << upper->first << ' ' << lower->first << " -> " << closest->first << std::endl;

    while( closest->second < 100 ) {
      std::cout << "skipping too low value " << closest->first << ' ' << closest->second << std::endl;
      closest == upper ? upper++ : lower--;
      setClosest( closest, upper, lower, key);
    }

    std::cout << key << ' ' << upper->first << ' ' << lower->first << " -> " << closest->first << std::endl;

  }

  return 0;
}

Exit

5000 10400 10400 -> 10400
5000 10400 10400 -> 10400
10000 10400 10400 -> 10400
10000 10400 10400 -> 10400
12000 12500 10400 -> 12500
skipping too low value 12500 99
12000 15200 10400 -> 10400
15000 15200 12500 -> 15200
skipping too low value 15200 67
skipping too low value 15400 76
skipping too low value 12500 99
15000 20200 10400 -> 10400
20000 20200 15400 -> 20200
20000 20200 15400 -> 20200
25000 25800 20200 -> 25800
25000 25800 20200 -> 25800