Connecting Tech Pros Worldwide Forums | Help | Site Map

Input Iterator needed for a for_each.

JeromeG
Guest
 
Posts: n/a
#1: Jul 22 '05
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

John Harrison
Guest
 
Posts: n/a
#2: Jul 22 '05

re: Input Iterator needed for a for_each.



"JeromeG" <jerome.gransac@exane.com> wrote in message
news:c647b437.0406240502.fec40@posting.google.com. ..[color=blue]
> 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:
>
>[/color]
////////////////////////////////////////////////////////////////////////////
///[color=blue]
> 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 );
>[/color]
////////////////////////////////////////////////////////////////////////////
///[color=blue]
>[/color]
[snip][color=blue]
>
> DOes anyone what to use as iterator (or something else?) to correct
> this warning?[/color]

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


Closed Thread