I have the following code:
return new std::pair<BST<Data>::iterator(cursor), true>;
This results in the following errors:
could not convert ‘(operator new(4u), (, ((int*))))’ from ‘int*’ to ‘std::pair, bool>’
type/value mismatch at argument 1 in template parameter list for ‘template struct std::pair’
What might be the problem here?
Apart from the
new(don’t use new unless you have to) andreturn, in order to construct apair, use either the mentionedmake_pair()function or invoke the constructor like this:pair<T1, T2>(v1, v2). You were mixing up the type (pair<T1, T2>) with the values to init that type’s instance (v1, v2).