What are you trying to return? A pair by value or really a pointer to a new object-pair? It could be useful to see the return type in the declaration of your function to know your intentions.
If you are trying to return a pair you better use:
template <class T1,class T2>
pair<T1,T2> make_pair (T1 x, T2 y)
{
return ( pair<T1,T2>(x,y) );
}
That is, something like:
return std::make_pair ( BST<Data>::iterator(cursor), true);
Or directly:
return ( pair<T1,T2>(x,y) );
That is, something like:
return ( std::pair< BST<Data>::iterator , bool>( cursor, true) );
If a pointer to a newly created object if what you want, use:
return ( new std::pair< BST<Data>::iterator , bool>( cursor, true) );
Now:
What might be the problem here?
Looking at:
template <class T1, class T2> struct pair
{
typedef T1 first_type;
typedef T2 second_type;
T1 first;
T2 second;
pair() : first(T1()), second(T2()) {}
pair(const T1& x, const T2& y) : first(x), second(y) {}
template <class U, class V>
pair (const pair<U,V> &p) : first(p.first), second(p.second) { }
};
You are trying to instantiate the template using values where we need types T1
and T2
.
std::make_pair
without thenew
and with a required boolean.