#include <map>
#include <iostream>
#include <algorithm>
#include <stdexcept>

//functor
struct finder {
    finder(int value_to_find) : v(value_to_find){}
    bool operator()(const std::pair<const int, int>& node) 
    {return node.second == v;}
protected:
    int v;
};

int find_value(const std::map<int, int>& container, int value_to_find) {
    typename std::map<int, int>::const_iterator it;
    it = std::find_if(container.begin(), container.end(), finder(value_to_find));
    if (it == container.end())
        throw std::runtime_error("value is not in container!");
    return it->first;
}

int main() {
    std::map<int, int> container;
    container[3] = 7;
    std::cout << find_value(container, 7);
}