|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
stdcxx compilation errorHello,
I try to compile this code with stdcxx (code which
compile with gcc + gccstl).
I don't understand why I get an error
void toto(const SentenceCompoundsData& compounds)
const
** for (std::map< Common::BagOfWords::BoWToken*, std::deque< PhoenixGraphVertex > >::const_iterator compoundsIt(compounds.begin());compoundsIt != compounds.end(); compoundsIt++) { ..... } } where SentenceCompoundsData is defined as typedef std::map< Common::BagOfWords::BoWToken*, std::deque< PhoenixGraphVertex >, CompareBoWTokenPtr > SentenceCompoundsData;OUTPUT : see attached file (error point to line **) I dont' know if it is a problem of STL or more a problem of compilation. If I try this, it works. for (SentenceCompoundsData ::const_iterator compoundsIt(compounds.begin());compoundsIt != compounds.end(); compoundsIt++) Thanks for help, Nadine Nadine Faizant
NewPhenix
Z.A. - 5, Rue de l'Auberte
30 133 Les Angles
Tél : 04 90 26 74 82
Fax : 04 90 26 90 84
Courriel : nadine.faizant@...
|
|
|
Re: stdcxx compilation errorAt a glance it appears that in the for loop you create a const iterator for:
std::map< key, value > which uses the default std::map comparator (std::less<key>) whereas the actual type of "compounds" is: std::map< key, value, CompareBoWTokenPtr > HTH. Nadine Faizant wrote: > Hello, > > I try to compile this code with stdcxx (code which compile with gcc + gccstl). > > I don't understand why I get an error > > void toto(const SentenceCompoundsData& compounds) const > ** for (std::map< Common::BagOfWords::BoWToken*, std::deque< PhoenixGraphVertex > >::const_iterator compoundsIt(compounds.begin());compoundsIt != compounds.end(); compoundsIt++) > > { > > ..... > > } > > } > > > where SentenceCompoundsData is defined as > typedef std::map< Common::BagOfWords::BoWToken*, std::deque< PhoenixGraphVertex >, CompareBoWTokenPtr > SentenceCompoundsData; > > OUTPUT : see attached file (error point to line **) > > I dont' know if it is a problem of STL or more a problem of compilation. If I try this, it works. > > for (SentenceCompoundsData ::const_iterator compoundsIt(compounds.begin());compoundsIt != compounds.end(); compoundsIt++) > > Thanks for help, > > Nadine > > > -------------------------------------------------------------------------------- > > Nadine Faizant > NewPhenix > Z.A. - 5, Rue de l'Auberte > 30 133 Les Angles > > > Tél : 04 90 26 74 82 > Fax : 04 90 26 90 84 > Courriel : nadine.faizant@... > > -------------------------------------------------------------------------------- > |
|
|
Re: stdcxx compilation errorThanks, I notice that. What I want to know, is it forbidden by VC or the STL or the use of template. Sorry, but I love c++ but hate template... so I don't know if the code is bad or not... :-( ----- Original Message ----- From: "Liviu Nicoara" <nicoara@...> To: <stdcxx-user@...> Sent: Thursday, November 16, 2006 5:04 PM Subject: Re: stdcxx compilation error > At a glance it appears that in the for loop you create a const iterator > for: > > std::map< key, value > > > which uses the default std::map comparator (std::less<key>) whereas the > actual type of "compounds" is: > > std::map< key, value, CompareBoWTokenPtr > > > HTH. > > Nadine Faizant wrote: >> Hello, >> >> I try to compile this code with stdcxx (code which compile with gcc + >> gccstl). >> >> I don't understand why I get an error >> >> void toto(const SentenceCompoundsData& compounds) const >> ** for (std::map< Common::BagOfWords::BoWToken*, std::deque< >> PhoenixGraphVertex > >::const_iterator >> compoundsIt(compounds.begin());compoundsIt != compounds.end(); >> compoundsIt++) >> >> { >> >> ..... >> >> } >> >> } >> >> >> where SentenceCompoundsData is defined as >> typedef std::map< Common::BagOfWords::BoWToken*, std::deque< >> PhoenixGraphVertex >, CompareBoWTokenPtr > SentenceCompoundsData; >> >> OUTPUT : see attached file (error point to line **) >> >> I dont' know if it is a problem of STL or more a problem of compilation. >> If I try this, it works. >> >> for (SentenceCompoundsData ::const_iterator >> compoundsIt(compounds.begin());compoundsIt != compounds.end(); >> compoundsIt++) >> >> Thanks for help, >> >> Nadine >> >> >> -------------------------------------------------------------------------------- >> >> Nadine Faizant NewPhenix Z.A. - 5, Rue de l'Auberte 30 133 Les Angles Tél >> : 04 90 26 74 82 Fax : 04 90 26 90 84 Courriel : >> nadine.faizant@... -------------------------------------------------------------------------------- >> > > |
|
|
Re: stdcxx compilation errorTemplates are good. :-)
The compiler complains that it cannot match what you gave it (std::map<key, value, std::less<key> >) with the actual type (std::map<key, value, custom_comparator>). To directly answer your question, it is an incorrect use of a template type, flagged by a compliant compiler, and the code in the "for" loop is "bad". Nadine Faizant wrote: > > Thanks, I notice that. What I want to know, is it forbidden by VC or > the STL or the use of template. Sorry, but I love c++ but hate template... > so I don't know if the code is bad or not... :-( > > ----- Original Message ----- From: "Liviu Nicoara" <nicoara@...> > To: <stdcxx-user@...> > Sent: Thursday, November 16, 2006 5:04 PM > Subject: Re: stdcxx compilation error > > >> At a glance it appears that in the for loop you create a const >> iterator for: >> >> std::map< key, value > >> >> which uses the default std::map comparator (std::less<key>) whereas >> the actual type of "compounds" is: >> >> std::map< key, value, CompareBoWTokenPtr > >> >> HTH. >> >> Nadine Faizant wrote: >>> Hello, >>> >>> I try to compile this code with stdcxx (code which compile with gcc + >>> gccstl). >>> >>> I don't understand why I get an error >>> >>> void toto(const SentenceCompoundsData& compounds) const >>> ** for (std::map< Common::BagOfWords::BoWToken*, std::deque< >>> PhoenixGraphVertex > >::const_iterator >>> compoundsIt(compounds.begin());compoundsIt != compounds.end(); >>> compoundsIt++) >>> >>> { >>> >>> ..... >>> >>> } >>> >>> } >>> >>> >>> where SentenceCompoundsData is defined as >>> typedef std::map< Common::BagOfWords::BoWToken*, std::deque< >>> PhoenixGraphVertex >, CompareBoWTokenPtr > SentenceCompoundsData; >>> >>> OUTPUT : see attached file (error point to line **) >>> >>> I dont' know if it is a problem of STL or more a problem of >>> compilation. If I try this, it works. >>> >>> for (SentenceCompoundsData ::const_iterator >>> compoundsIt(compounds.begin());compoundsIt != compounds.end(); >>> compoundsIt++) >>> >>> Thanks for help, >>> >>> Nadine >>> >>> >>> -------------------------------------------------------------------------------- >>> >>> >>> Nadine Faizant NewPhenix Z.A. - 5, Rue de l'Auberte 30 133 Les Angles >>> Tél : 04 90 26 74 82 Fax : 04 90 26 90 84 Courriel : >>> nadine.faizant@... >>> -------------------------------------------------------------------------------- >>> >>> >> >> > > > |
|
|
Re: stdcxx compilation errorNadine Faizant wrote:
> > Thanks, I notice that. What I want to know, is it forbidden by VC or > the STL or the use of template. As Liviu says, the two types are (most likely) incompatible. You didn't show us the definition of CompareBoWTokenPtr so we can't tell for 100% certain that it's not a typedef for std::less but it seems like a pretty safe bet that it isn't given that you get the errors. Since you know the type of the container is SentenceCompoundsData you should use it consistently throughout your code. That way, when the type changes, you don't have to change all the places where you referred to it by the actual type instead of the alias. Martin > Sorry, but I love c++ but hate template... > so I don't know if the code is bad or not... :-( > > ----- Original Message ----- From: "Liviu Nicoara" <nicoara@...> > To: <stdcxx-user@...> > Sent: Thursday, November 16, 2006 5:04 PM > Subject: Re: stdcxx compilation error > > >> At a glance it appears that in the for loop you create a const >> iterator for: >> >> std::map< key, value > >> >> which uses the default std::map comparator (std::less<key>) whereas >> the actual type of "compounds" is: >> >> std::map< key, value, CompareBoWTokenPtr > >> >> HTH. >> >> Nadine Faizant wrote: >> >>> Hello, >>> >>> I try to compile this code with stdcxx (code which compile with gcc + >>> gccstl). >>> >>> I don't understand why I get an error >>> >>> void toto(const SentenceCompoundsData& compounds) const >>> ** for (std::map< Common::BagOfWords::BoWToken*, std::deque< >>> PhoenixGraphVertex > >::const_iterator >>> compoundsIt(compounds.begin());compoundsIt != compounds.end(); >>> compoundsIt++) >>> >>> { >>> >>> ..... >>> >>> } >>> >>> } >>> >>> >>> where SentenceCompoundsData is defined as >>> typedef std::map< Common::BagOfWords::BoWToken*, std::deque< >>> PhoenixGraphVertex >, CompareBoWTokenPtr > SentenceCompoundsData; >>> >>> OUTPUT : see attached file (error point to line **) >>> >>> I dont' know if it is a problem of STL or more a problem of >>> compilation. If I try this, it works. >>> >>> for (SentenceCompoundsData ::const_iterator >>> compoundsIt(compounds.begin());compoundsIt != compounds.end(); >>> compoundsIt++) >>> >>> Thanks for help, >>> >>> Nadine >>> >>> >>> -------------------------------------------------------------------------------- >>> >>> >>> Nadine Faizant NewPhenix Z.A. - 5, Rue de l'Auberte 30 133 Les Angles >>> Tél : 04 90 26 74 82 Fax : 04 90 26 90 84 Courriel : >>> nadine.faizant@... >>> -------------------------------------------------------------------------------- >>> >>> >> >> > > |
| Free embeddable forum powered by Nabble | Forum Help |