#include <iostream>
#include <vector>
#include <unordered_map>

typedef std::pair<std::string::const_iterator,std::string::const_iterator> FindType;

FindType findSubKey(std::string &S) {
  auto a = S.find_first_of('a');   
  auto b = S.find_last_of('f');
  std::cout << a << ":" << b <<std::endl;  
  return {S.begin()+a,S.begin()+b};    
}

int main () {
    std::unordered_map<std::string, int> map = {
      {"123",3},
      {"123456abcdefx",2},
      {"abcde",7},  
      {"6abcdef",1}
    };
    std::string bigString = "123abcdefjhk";
    std::string::const_iterator subKeyBegin, subKeyEnd;
    std::tie(subKeyBegin, subKeyEnd) = findSubKey(bigString);
    //////////////////////////////////////////////////////////////////
    std::string Tmp = "";
    Tmp.reserve(bigString.size());
    //////////////////////////////////////////////////////////////////
    Tmp.assign(subKeyBegin,subKeyEnd);
    std::cout << "\"" << Tmp << "\"" << std::endl;
    std::cout << (map.find(Tmp)!=map.end() ? "Нашли":"Не нашли") << std::endl;
  return 0;
}