Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unordered_map<int, int> storeinhashmap(vector<int>v, int n)
- {
- vector<int>::iterator it=v.begin();
- unordered_map<int,int>h;
- int temp;
- while(n--)
- {
- temp = *it;
- h.insert(make_pair<int,int>(n,*it));
- it++;
- }
- return h;
- }
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- int n, x;
- cin>>n;
- vector<int>v;
- readValues(v, n);
- cin>>x;
- unordered_map<int, int>h = storeinhashmap(v, n);
- //char ans = checksumisx(h, n);
- }
- return 0;
- }
- harshit@harshit-5570:~/Desktop/geeksforgeeks$ g++ -std=c++14 key_pair.cpp
- key_pair.cpp: In function ‘std::unordered_map<int, int> storeinhashmap(std::vector<int>, int)’:
- key_pair.cpp:26:43: error: no matching function for call to ‘make_pair(int&, int&)’
- h.insert(make_pair<int,int>(n, *it));
- ^
- In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
- from /usr/include/c++/5/bits/char_traits.h:39,
- from /usr/include/c++/5/ios:40,
- from /usr/include/c++/5/ostream:38,
- from /usr/include/c++/5/iostream:39,
- from key_pair.cpp:1:
- /usr/include/c++/5/bits/stl_pair.h:276:5: note: candidate: template<class _T1, class _T2> constexpr std::pair<typename std::__decay_and_strip<_Tp>::__type, typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&)
- make_pair(_T1&& __x, _T2&& __y)
- ^
- /usr/include/c++/5/bits/stl_pair.h:276:5: note: template argument deduction/substitution failed:
- key_pair.cpp:26:43: note: cannot convert ‘n’ (type ‘int’) to type ‘int&&’
- h.insert(make_pair<int,int>(n, *it));
Add Comment
Please, Sign In to add comment