template class MyUniqueDictionary T1 key; T2 value; T3 size; std::vector> dictionar; public: MyUniqueDictionary() : size(5), key(0) {} MyUniqueDictionary(const T3& x) : size(x), key(0) {} virtual ~MyUniqueDictionary() { size = 0; } inline void insertElement(T1, T2); inline std::pair getElement(T1); friend std::ostream& operator<<(std::ostream& out, std::pair x){ return out << "(" << x.first << ", " << x.second << " )\n"; T2& operator()(const T1); std::vector> getDictionar(); inline void printContent(); template void MyUniqueDictionary::printContent() { auto it = dictionar.begin(); for (auto i = 0; i < dictionar.size(); ++i) std::cout<<(*(it + i)).first << ", " << (*(it + i)).second<< std::endl; template std::vector> MyUniqueDictionary::getDictionar() { return dictionar; template T2& MyUniqueDictionary::operator()(const T1 h) for (int i = 0; i < dictionar.size(); i++) if (h == dictionar[i].first) return dictionar[i].second; template void MyUniqueDictionary::insertElement(T1 c, T2 val) { dictionar.push_back(std::make_pair(c, val)); template T2 getValue(T1 y) { auto it = MyUniqueDictionary::dictionar.begin(); for (auto i = 0; i < MyUniqueDictionary::dictionar.size(); ++i) if (MyUniqueDictionary::dictionar[i].first == y) return MyUniqueDictionary::dictionar[i].second; return; template std::pair MyUniqueDictionary::getElement(T1 y) { for (auto i = 0; i < dictionar.size(); ++i) if (dictionar[i].first == y) return dictionar[i]; return std::make_pair(-1,"invalid"); int main() MyUniqueDictionary firstDict(5); MyUniqueDictionary<> secondDict; firstDict.insertElement(150, "Valoare_cheie_150"); firstDict.insertElement(155, "Valoare_cheie_155"); firstDict.printContent(); //std::cout << firstDict.getElement(150) << "\n"; secondDict.insertElement(160, "Valoare_cheie_160"); secondDict.insertElement(155, "Valoare_cheie_155"); secondDict.printContent(); return 0;

Can anyone help me? may be the Argument-dependent lookup but I don't know how to resolve it. I have searched online and found that argument dependent lookup could be the issue and the definition in namespace std should help but it didnt or include string , include iostream, include vector also did not help.

The line commented in main function doesn't work. Do anyone know how to solve it?

Maybe use this standalone, non-member template function instead -

   template< typename T1, typename T2>  
   std::ostream& operator <<(std::ostream& out, std::pair<T1, T2>& x)  
       return out << "(" << x.first << ", " << x.second << " )\n";  
												

Still fails... other people said that the problem here is that i am trying to overload the operator << to work with std::ostream and std::pair<int, std::string>, neither of which is a user-defined type but i defined a structure

 struct mine{  
    	int a;  
    	std::string b;  

Still the same error.

std::ostream& operator <<(std::ostream& out, const mine& x) { . . . }  
template< typename T1, typename T2>  
std::ostream& operator <<(std::ostream& out, const std::pair<T1, T2>& x) { . . . }