473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

no match for 'operator!=' in ...

I'm having a few issues porting Windows code to Linux (VS.Net 2003 to
GCC 4.0.1). So this probably has something to do with VS not catching
non-compliant code. I'd like to simplify this problem, but I'm not
really sure what the issue is. I appologize in advance, as this
doesn't give you much to go on. Basically, I want to compare my own
iterators with stl vector iterators. I've written the operator== and
operator!= functions to do this (actually, they're methods... I
couldn't figure out how to make them static functions due to a host of
other issues we probably don't need to get into). I'm hoping that
maybe somebody can spot a clue in the error message. Here's the
problem code:

CHAIN_CONTAINER::const_iterator stl_itEnd =
my_itChain->getOwner()->getChains().end();

if (my_itChain != stl_itEnd) // OK
do_something();

fi (my_itChain != my_itChain->getOwner()->getChains().end()) // GCC
complains
do_something();
Here's the error message I'm getting on the fourth line:
ContainerChild.cpp: In member function 'ContainerChild::pjt_iterator
ContainerChild::beginPJT(Container<A, B, C, D>::c_iterator&)':
ContainerChild.cpp:133: error: no match for 'operator!=' in 'itC !=
(+(+ itC)->Container<T1, T2, T3, T4>::c_iterator::operator-> [with T1 =
A, T2 = B, T3 = C, T4 =
D]()->C::getOwner()->B::<anonymous>.BParent::getChains())->std::vector<_Tp,
_Alloc>::end [with _Tp = CParent*, _Alloc =
std::allocator<CParent*>]()'
.../common/Container.h:223: note: candidates are: bool Container<T1, T2,
T3, T4>::c_iterator::operator!=(const Container<T1, T2, T3,
T4>::c_iterator&) [with T1 = A, T2 = B, T3 = C, T4 = D]
.../common/Container.h:225: note: bool Container<T1, T2,
T3, T4>::c_iterator::operator!=(__gnu_cxx::__normal_it erator<CParent*
const*, std::vector<CParent*, std::allocator<CParent*> > >&) [with T1 =
A, T2 = B, T3 = C, T4 = D]

Thanks in advance!

Dec 28 '05 #1
2 25641
Mr Dyl wrote:
I'm having a few issues porting Windows code to Linux (VS.Net 2003 to
GCC 4.0.1). So this probably has something to do with VS not catching
non-compliant code. I'd like to simplify this problem, but I'm not
really sure what the issue is. I appologize in advance, as this
doesn't give you much to go on. Basically, I want to compare my own
iterators with stl vector iterators. I've written the operator== and
operator!= functions to do this (actually, they're methods... I
couldn't figure out how to make them static functions due to a host of
other issues we probably don't need to get into). I'm hoping that
maybe somebody can spot a clue in the error message. Here's the
problem code:

CHAIN_CONTAINER::const_iterator stl_itEnd =
my_itChain->getOwner()->getChains().end();

if (my_itChain != stl_itEnd) // OK
do_something();

fi (my_itChain != my_itChain->getOwner()->getChains().end()) // GCC
complains
do_something();
Here's the error message I'm getting on the fourth line:
ContainerChild.cpp: In member function 'ContainerChild::pjt_iterator
ContainerChild::beginPJT(Container<A, B, C, D>::c_iterator&)':
ContainerChild.cpp:133: error: no match for 'operator!=' in 'itC !=
(+(+ itC)->Container<T1, T2, T3, T4>::c_iterator::operator-> [with T1 =
A, T2 = B, T3 = C, T4 =
D]()->C::getOwner()->B::<anonymous>.BParent::getChains())->std::vector<_Tp,
_Alloc>::end [with _Tp = CParent*, _Alloc =
std::allocator<CParent*>]()'
../common/Container.h:223: note: candidates are: bool Container<T1, T2,
T3, T4>::c_iterator::operator!=(const Container<T1, T2, T3,
T4>::c_iterator&) [with T1 = A, T2 = B, T3 = C, T4 = D]
../common/Container.h:225: note: bool Container<T1, T2,
T3, T4>::c_iterator::operator!=(__gnu_cxx::__normal_it erator<CParent*
const*, std::vector<CParent*, std::allocator<CParent*> > >&) [with T1 =
A, T2 = B, T3 = C, T4 = D]


Whew. Could you tell us:

1) the exact type (const or not) of my_itChain
2) the exact type (const or not) of
my_itChain->getOwner()->getChains().end()
3) the declaration of your operator!=().
Jonathan

Dec 28 '05 #2
Whew is right! It turned out to be quite the red herring. I figured
out (sort of) what was going on while typing out a reply to your post.
My operator== and operator!= RHS arguments weren't const references.
Ooops. Anyway, if you're interested below are the answers to your
questions. I put the const error in CAPS.

I also noticed that I should have rewritten the code snippet to make
it a tad easier to read in relation to the error message. Here it is
again:

std::vector<C*>::const_iterator stl_itEnd =
my_itC->getOwner()->getCs().end();
if (my_itC != stl_itEnd) // OK
do_something();

if (my_itC != my_itC->getOwner()->getCs().end()) // GCC complains
do_something();

Your questions...

1) The type for 'my_itC' is a nested class declared inside Container.
See below.
2) As it appears above (ie. std::vector<C*>::const_iterator )
3) See below as well.

template<typename T1, typename T2, typename T3, typename T4>
class Container {
public:
class a_iterator {
public:
bool operator==(CONST std::vector<A*>::const_iterator& itRHS)
{return(m_itA == itRHS);}
bool operator!=(CONST std::vector<A*>::const_iterator& itRHS)
{return(!(*this == itRHS));}
protected:
std::vector<A*>::iterator m_itA;
...
};

class b_iterator : a_iterator {
public:
bool operator==(CONST std::vector<B*>::const_iterator& itRHS)
{return(m_itB == itRHS);}
bool operator!=(CONST std::vector<B*>::const_iterator& itRHS)
{return(!(*this == itRHS));}
protected:
std::vector<B*>::iterator m_itB;
...
};

class c_iterator : b_iterator {
public:
bool operator==(CONST std::vector<C*>::const_iterator& itRHS)
{return(m_itC == itRHS);}
bool operator!=(CONST std::vector<C*>::const_iterator& itRHS)
{return(!(*this == itRHS));}
protected:
std::vector<C*>::iterator m_itC;
...
};

class d_iterator : c_iterator {
public:
bool operator==(CONST std::vector<D*>::const_iterator& itRHS)
{return(m_itD == itRHS);}
bool operator!=(CONST std::vector<D*>::const_iterator& itRHS)
{return(!(*this == itRHS));}
protected:
std::vector<D*>::iterator m_itD;
...
};
...
};

class ContainerChild : public Container <A, B, C, D> {
};

Dec 29 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dai Kane | last post by:
Am experimenting with some range-bound numeric class thingy, and now wondering this situation: int a = 10; myclass b(6); if ( a > b ) { ... }
19
by: Tom Deco | last post by:
Hi, I'm trying to use a regular expression to match a string containing a # (basically i'm looking for #include ...) I don't seem to manage to write a regular expression that matches this. ...
0
by: santana | last post by:
Hi I've created a class to be used with stl vector. I'm having a hard time decipher the error message outpout by g++... burlen@quaoar:~/hdf52vtk_dev/src$ g++ junk.cpp GridPoint.o...
6
by: hopangtsun | last post by:
Hello all, I've got a problem on operator overloading, I don't know what's wrong with my code. Can anyone kindly tell me what's the problem is? Thanks //this is the error message I've got...
2
by: Arvid Requate | last post by:
Hello, I'd like to understand why the following code does not compile. It looks like a strangeness in connection with overload resolution for the <complex> header: The conversion operator...
1
by: runistel | last post by:
i cant seem to find any fault, can anyone point out the error? void Itinerary::print() { list<Place>::iterator i; for(i = placelist.begin(); i != placelist.end(); i++) { cout...
4
by: fantasticamir | last post by:
Guys, is it ok?? class B{ .... };
1
by: orangemonkey | last post by:
#include <iostream> #include <math.h> #include <vector> using namespace std; int main (void) { int sv = 0, fv = 0; cout << "Start Value:" << endl;
8
by: redbeardmcg | last post by:
Hi everyone, I'm having an issue splitting a string with preg_split.... Here is a sample string: congestion >= 80 Where >= could also be <=, ==, !=, < or > What I need to accomplish is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.