#include <utility>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>

template <typename container_type>
typename container_type::iterator find_by_key(container_type& container, 
				const typename container_type::value_type::first_type& key) 
{
    typedef typename container_type::value_type element_type;

    return std::find_if(std::begin(container), std::end(container), 
    			[&](const element_type& k) { return key == k.first; });
}

int main()
{
    typedef std::pair<unsigned, std::string> element_type;

    std::vector<element_type> v =
    {
        {  1, "One"   },
        {  3, "Three" },
        {  5, "Five"  },
        {  7, "Seven" },
        {  9, "Nine"  },
        { 10, "Ten"   },
        {  8, "Eight" },
        {  6, "Six"   },
        {  4, "Four"  },
        {  2, "Two"   }
    };

    std::cout << "By key:\n";
    for (unsigned i = 1; i < 11; ++i)
    {
        std::vector<element_type>::iterator it = find_by_key(v, i);

        std::cout << '\t' << i << " | ";

        if (it != v.end())
            std::cout << it->second << '\n';
        else
            std::cout << "(null)\n";
    }

    std::cout << "\n\nBy position:\n";
    for (unsigned i = 0; i < v.size(); ++i)
    {
        std::cout << "\tpos: " << i << ": " ;
        std::cout << v[i].first << " | " <<  v[i].second << '\n';
    }
}