GCC: "no known conversion from someClass to someClass&"

Hi, could you please help me understand this error message? I have a function taking an object of some class by reference, and it gives me this error message when compiled with either GCC or Clang. The relevant code is as shown below:

1
2
3
bool foundInTree = (testContainer.find(i) != testContainer.end());
//find returns a custom defined const_iterator object for testContainer
//testContainer is a const reference to some custom defined container 


that's the line producing the error, and this is the function:
1
2
3
4
template <typename T>
bool operator!=(const_btree_iterator<T>& one,btree_iterator<T>& other){
	return !(other == one);
}


what the error message says is that the compiler can't "convert" from const_btree_iterator<T>, which is returned by testContainer.find(i), to const_btree_iterator<T>&, which is what's expected. Could I have some help please? Thanks in advance
Well one parameter is const_btree_iterator and the other btree_iterator.
So change the second to be const_btree_iterator as well.

You have to overload begin() in the custom container to return a const_btree_iterator, if it wasn't already.

1
2
3
4
template <typename T>
bool operator!=(const_btree_iterator<T>& one, const_btree_iterator<T>& other){
	return !(other == one);
}

hi, thanks for the quick reply. I've actually written a series of overloaded functions that compare const_iterators and iterators with each other. I've found out that the cause of the error is that I'm trying to bind a non-constant reference to an rvalue. Thank you anyway for your help.
Topic archived. No new replies allowed.