473,468 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

STL generated warnings

Hi,

I'm currently using Borland C++ Builder on an application using the STL,
and it generates warnings I don't know how to handle:

"[C++ Warning] Unit1.cpp(585): W8091 Argument template, _InputIter sent
to 'for_each' is an output iterator: input iterator required
Complete Analyzer Context:
Unit1.cpp(574): analysis :, void TForm1::UpdateDBListBox()"

(rougly translated from the french).

Here's the code:

{
multiset<DBCard, CardCompare> List;
for_each(List.begin(), List.end(), AddItem);
}

(Actually everywhere I use a for_each on a multi set).
I've looked at the SGI doc on iterators, for_each and multiset but I
must admit I feel none the wiser.
What do I do wrong, and how do it write, please?

Thanks,
Moah, full time turnip.

Jul 19 '05 #1
8 2464

"Moah, full time turnip." <mo**@micronet.fr> wrote in message
news:bk**********@news-reader7.wanadoo.fr...
Hi,

I'm currently using Borland C++ Builder on an application using the STL,
and it generates warnings I don't know how to handle:

"[C++ Warning] Unit1.cpp(585): W8091 Argument template, _InputIter sent
to 'for_each' is an output iterator:
Complete Analyzer Context:
Unit1.cpp(574): analysis :, void TForm1::UpdateDBListBox()"

(rougly translated from the french).

Here's the code:

{
multiset<DBCard, CardCompare> List;
for_each(List.begin(), List.end(), AddItem);
}

(Actually everywhere I use a for_each on a multi set).
Well, do you have the same problems those other places?
I've looked at the SGI doc on iterators, for_each and multiset but I
must admit I feel none the wiser.
What do I do wrong, and how do it write, please?


Hard to say with only that partial context. Here's
an example of 'for_each()' operating on a multiset
that compiles just fine and gives expected results:

#include <algorithm>
#include <iostream>
#include <set>

void f(int arg)
{
std::cout << arg << '\n';
}

int main()
{
std::multiset<int> ms;
ms.insert(0);
ms.insert(42);
ms.insert(3);
ms.insert(42);
ms.insert(99);
std::for_each(ms.begin(), ms.end(), f);
return 0;
}

Output:

0
3
42
42
99

HTH,
-Mike
Jul 19 '05 #2
Moah, full time turnip. wrote:
Hi,

I'm currently using Borland C++ Builder on an application using the STL,
and it generates warnings I don't know how to handle:

"[C++ Warning] Unit1.cpp(585): W8091 Argument template, _InputIter sent
to 'for_each' is an output iterator: input iterator required
Complete Analyzer Context:
Unit1.cpp(574): analysis :, void TForm1::UpdateDBListBox()"
(rougly translated from the french).
I think you've found a bug. According to SGI's documentation, multiset
models Associative Container, which refines Container, which refines
Forward Container, and the iterator type of a Forward Container is
required to be an input iterator. If the code works as you expect
(it may be difficult to determine whether or not this is the case)
then, in my opinion, you should feel free to ignore or disable the
warning.
Here's the code:

{
multiset<DBCard, CardCompare> List;
for_each(List.begin(), List.end(), AddItem);
}

(Actually everywhere I use a for_each on a multi set).
I've looked at the SGI doc on iterators, for_each and multiset but I
must admit I feel none the wiser.
What do I do wrong, and how do it write, please?


What version of Builder are you using?

Regards,
Buster.

Jul 19 '05 #3
Moah, full time turnip. <mo**@micronet.fr> wrote:
Hi, I'm currently using Borland C++ Builder on an application using the STL,
and it generates warnings I don't know how to handle: "[C++ Warning] Unit1.cpp(585): W8091 Argument template, _InputIter sent
to 'for_each' is an output iterator: input iterator required
Complete Analyzer Context:
Unit1.cpp(574): analysis :, void TForm1::UpdateDBListBox()" (rougly translated from the french). Here's the code: {
multiset<DBCard, CardCompare> List;
please dont call a multiset a "List", this is misleading :-)

a std::multiset only takes 1 template parameter, since
sets only carry a set of elements. I dont know if you
want a multiset of std::pair<DBCard, CardCompare>,
or only of the DBCard _or_ CardCompare.
(Actually everywhere I use a for_each on a multi set).
I've looked at the SGI doc on iterators, for_each and multiset but I


here is an example:
http://www.sgi.com/tech/stl/multiset.html

hope this helps
Joerg
--
Simplicity is prerequisite for reliability.
Edsger W. Dijkstra
Jul 19 '05 #4
Buster Copley wrote:
I think you've found a bug. According to SGI's documentation, multiset
models Associative Container, which refines Container, which refines
Forward Container, and the iterator type of a Forward Container is
required to be an input iterator. If the code works as you expect
(it may be difficult to determine whether or not this is the case)
then, in my opinion, you should feel free to ignore or disable the
warning.
Ok, I was wondering about that. Especially since the code works fine.
What version of Builder are you using?
Borland C++ Builder 6 Enterprise trial. Planning to buy the personal
edition when my trial expires...
Regards,
Buster.


Moah, full time turnip.
Jul 19 '05 #5
Mike Wahler wrote:
Well, do you have the same problems those other places?
I get the exact same problem wherever I use for_each on my multiset,
but they are more or less the same thing as what I pasted.
Hard to say with only that partial context. Here's
an example of 'for_each()' operating on a multiset
that compiles just fine and gives expected results:


Thanks. Mine gives the warning, but as far as I've seen, there's
no mis-behaviour.

Moah, full time turnip.

Jul 19 '05 #6
Joerg Beyer wrote:
multiset<DBCard, CardCompare> List;
a std::multiset only takes 1 template parameter, since
sets only carry a set of elements. I dont know if you
want a multiset of std::pair<DBCard, CardCompare>,
or only of the DBCard _or_ CardCompare.
According to SGI, you can specify the comparison function to apply
for the sorting of the set/multi set. CardCompare is a functor that
compares DBCard based on external criterions:

multiset<Key, Compare, Alloc>

Key: The set's key type and value type. This is also defined as
multiset::key_type and multiset::value_type

Compare: The key comparison function, a Strict Weak Ordering whose
argument type is key_type; it returns true if its first argument is less
than its second argument, and false otherwise. This is also defined as
multiset::key_compare and multiset::value_compare.
Default: less<Key>

Alloc: The multiset's allocator, used for all internal memory mana-
gement.
Default: alloc
here is an example:
http://www.sgi.com/tech/stl/multiset.html hope this helps
Joerg


Thanks,
Moah, full time turnip.

Jul 19 '05 #7
"Moah, full time turnip." <mo**@micronet.fr> wrote in message news:<bk**********@news-reader7.wanadoo.fr>...
I'm currently using Borland C++ Builder on an application using the STL,
and it generates warnings I don't know how to handle:

"[C++ Warning] Unit1.cpp(585): W8091 Argument template, _InputIter sent
to 'for_each' is an output iterator: input iterator required
Complete Analyzer Context:
Unit1.cpp(574): analysis :, void TForm1::UpdateDBListBox()"

(rougly translated from the french).

Here's the code:
The code snippet you provided doesn't compile by itself, so I added
the following:

#include <algorithm>
#include <functional>
#include <set>

using std::multiset;
using std::for_each;

typedef int DBCard;
typedef std::less<DBCard> CardCompare;
void AddItem (DBCard) { }

int main ()
{
multiset<DBCard, CardCompare> List;
for_each(List.begin(), List.end(), AddItem);
}


With my changes, Comeau (www.comeaucomputing.com/tryitout) compiles
it. It could be something in the code you didn't show us, but I can't
imagine how that might happen. More likely, it's some sort of bug in
Borland's implementation. If this is the case, direct your news reader
to the forums.borland.com news server, or use its Web gateway at
<http://forums.borland.com/>.

- Shane
Jul 19 '05 #8
Shane Beasley wrote:

The code snippet you provided doesn't compile by itself, so I added
the following:
.... snip the actual code ...
With my changes, Comeau (www.comeaucomputing.com/tryitout) compiles
it. It could be something in the code you didn't show us, but I can't
imagine how that might happen. More likely, it's some sort of bug in
Borland's implementation. If this is the case, direct your news reader
to the forums.borland.com news server, or use its Web gateway at
<http://forums.borland.com/>.
I copied / pasted your modified code into Borland C++ Builder, set the
warnings settings to "all" as in my normal project, and I got exactly
the same warnings. I have reported it in the Borland newsgroup, but I'll
check their web gateway jic my new server is out of date.
- Shane


Thanks a lot,
Moah, full time turnip.

Jul 19 '05 #9

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

Similar topics

10
by: Kylotan | last post by:
I have the following code: def IntToRandFloat(x): """Given a 32-bit integer, return a float in """ x = int(x) x = int(x << 13) ^ x return...
0
by: Steve Barker | last post by:
Hi guys! In Visual Studio .NET, I like to enable auto-generation of XML documentation on the project properties screen, by adding an XML file name under "Configuration Properties" --> "Build"...
22
by: John Fisher | last post by:
void f(int p) { } Many (most?) compilers will report that p is unreferenced here. This may not be a problem as f may have to match some common prototype. Typically pointers to functions are...
2
by: dbuchanan | last post by:
I built a simple Data Access Layer with the Visual Studio 2005 DataSet Designer using the wizard. All who I have talked to who use it, articles I haver read by those who use it speak very highly...
1
by: Skip Sailors | last post by:
I want code I write to have XML comments that are correct and I want the compiler to fail to build is I mess up a comment, but I don't want generated code to cause a build failure. Is there a way...
3
by: Rolf Welskes | last post by:
Hello, this is a hint only. If you make a custom control for example witch generates code <div......</div> and I put such a control in a page then in html-view of the aspx-file I could...
2
by: theinvisibleGhost | last post by:
Is it possible in someway to write code, that will flag up a warning at compile time as a kind of reminder? I was thinking something along the lines of Compiler.Warnings.Add("This Method is...
3
by: gil | last post by:
Hi, I'm trying to find the best way to work with compiler warnings. I'd like to remove *all* warnings from the code, and playing around with the warning level, I've noticed that compiling with...
1
by: Robert Singer | last post by:
Platform: winXP, excel 2003 Python 2.5.2 XLWriter 0.4a3 (http://sourceforge.net/projects/pyxlwriter/) Is anyone here using this very nice package, for writing excel files? I'm using it on...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.