次のコードにエラーがあります。
(Visual Studio エラー:) エラー 5 エラー C2678: バイナリ '!=' : タイプ '`ノード' の左側のオペランドを取る演算子が見つかりません (または、受け入れ可能な変換がありません)
template <class C, class T>
C find2 ( C first , C last, T c )
{
//
while ( first != last && *first != c )
{
++first;
}
return first;
}
struct Node
{
Node(int a ,Node* b):val(a),next(b){};
int val;
Node* next;
};
template <class T>
struct node_wrap
{
T* ptr;
node_wrap ( T* p = 0 ) : ptr ( p ) {}
Node& operator*() const {return *ptr;}
Node* operator->() const {return ptr;}
node_wrap& operator++ () {ptr = ptr->next; return * this;}
node_wrap operator++ ( int ) {node_wrap tmp = *this; ++*this; return tmp;}
bool operator== ( const node_wrap& i ) const {return ptr == i.ptr;}
bool operator!= ( const node_wrap& i ) const {return ptr != i.ptr;}
};
bool operator== ( const Node& node, int n )
{
return node.val == n;
}
int main()
{
Node* node1=new Node(3,NULL);
Node* node2=new Node(4,NULL);
node1->next = node2;
find2 ( node_wrap<Node>(node1), node_wrap<Node>(), 3) ) ;
delete node1;
delete node2;
return 0;
}
このコードの何が問題になっていますか?