Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make_pair

Status
Not open for further replies.

joeGrammar

Programmer
Jun 4, 2001
162
CA
Notice this bit of template code:

#include <map>
#include <algorithm>

template<class K, class V>
class LookupList : public map<K,V>
{
public:
typedef map<K,V> map_type;

public:
LookupList(const V& v) : vDefault(v) {};
~LookupList() {};
bool AddPair( const K& k, const V& v ) {
return map<K,V>::insert(make_pair<const K, V>(k,v)).second;
};

{ FYI Here is the code for insert from <map>

_Pairib insert(const value_type& _X)
{_Imp::_Pairib _Ans = _Tr.insert(_X);
return (_Pairib(_Ans.first, _Ans.second)); }
}


I'm getting errors on the make_pair function:

error C2667: 'make_pair' : none of 2 overload have a best conversion

error C2668: 'make_pair' : ambiguous call to overloaded function


In the file, the make_pair variable is declared in the std namespace like so..:

using std::make_pair;

Now I haven't worked with make_pair before and I don't know where it comes from, I'm assuming its making an ordered pair. My question is where is the code for make_pair and why am I getting these error messages, the code itself looks fine unless make_pair itself can't handle these types of template parameters... any thoughts?

Thanks


 
OK can anyone tell me why when I took out

using std::make_pair

the errors went away and it compiled fine? I'm baffled
 
I think simply you to write 'using namespace std;' in uour cpp after includes. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top