Input Iterator needed for a for_each.

J

JeromeG

Hi,

I have a project that use to be developped on WIndows NT 4.0 sp6a and
Borland c++ builder 5.0.
Now this project has been compiled and linked on Windows XP and
Borland c++ 6.0.

The reason i am writting this note on this group is the following:
I have a warning on each std::for_each use.
This warning is : Warning W8091
"Argument template, _InputIter passed to "for_each" is an ouput
iterator : input iterator required"

Befor with BCB5, i have no warnings on the using of for_each. Here are
the code lines:

///////////////////////////////////////////////////////////////////////////////
std::set<VM_CleElement>::const_iterator it1 =
fElementsToujoursVisibles.begin();
std::set<VM_CleElement>::const_iterator it2 =
fElementsToujoursVisibles.end();
VM_SauvegardeCleElements toto(registry.get(),
"ElementToujoursVisible");
std::for_each(it1, it2, toto );
///////////////////////////////////////////////////////////////////////////////

with declaration as following:
///////////////////////////////////////////////////////////////////////////////
class CFG_Configuration::VM_SauvegardeCleElements
{
TRegistry * fRegistry;
AnsiString fValeur;
long fIndex;
public:
VM_SauvegardeCleElements( TRegistry * _registry, const char *
_valeur);

void operator()( const CFG_Configuration::VM_CleElement & _elt);
};
///////////////////////////////////////////////////////////////////////////////

DOes anyone what to use as iterator (or something else?) to correct
this warning?
Thx for all ur answers !
Any help would be very appreciated.
Jerome
 
J

John Harrison

JeromeG said:
Hi,

I have a project that use to be developped on WIndows NT 4.0 sp6a and
Borland c++ builder 5.0.
Now this project has been compiled and linked on Windows XP and
Borland c++ 6.0.

The reason i am writting this note on this group is the following:
I have a warning on each std::for_each use.
This warning is : Warning W8091
"Argument template, _InputIter passed to "for_each" is an ouput
iterator : input iterator required"

Befor with BCB5, i have no warnings on the using of for_each. Here are
the code lines:

////////////////////////////////////////////////////////////////////////////
///
std::set<VM_CleElement>::const_iterator it1 =
fElementsToujoursVisibles.begin();
std::set<VM_CleElement>::const_iterator it2 =
fElementsToujoursVisibles.end();
VM_SauvegardeCleElements toto(registry.get(),
"ElementToujoursVisible");
std::for_each(it1, it2, toto );
////////////////////////////////////////////////////////////////////////////
///[snip]

DOes anyone what to use as iterator (or something else?) to correct
this warning?

The code is correct, the warning is wrong. std::set<T>::const_iterator is an
input iterator.

I don't know what you need to do to fix the warning, but if you can just
ignore it, it is clearly incorrect.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top