The first observation would be that std::map would not be the most efficient structure anyway. Your input is pretty much corrected, apparently (from the comments). In this case, std::binary_search on a sorted std::vector is more efficient. The main advantage of std::map over std::vector is that the insert is O (log N) instead of O (N), and you don't need it.
The next observation would be that you can allow yourself a little inaccurate in the first step. Your output set is likely to be much smaller than the total number of points (otherwise a linear search will be fine). But assuming this is so, you can take advantage of rounding the rectangle. This will result in more candidate points, which you then check against the exact border.
For example, if your points were randomly distributed in the XY plane between (0,0) and (200,300), you could create a 20x30 matrix, each of which had a 10.10 subarea. If now you need points in the rectangle from (64,23) to (78, 45), you need to check the subareas [6,2], [6,3], [6,4], [7,2], [7,3] and [7,4] - only 6 out of 600. In the second stage, you throw out results such as (61, 25).
source share