Compile Errors Due to STL & Iterator

Status
Not open for further replies.
Hi.

I posted two threads earlier about STL and cin, cout, ifstream and ofstream. I implemented code based on inputs from other members.

Here is the code:


void ScanList::scanData(ifstream &source, ofstream &output)
{
string oneLine;
std::deque dataList;

while(veri)
{
std::getline(source, oneLine);

if (oneLine[0] == NULL || !isdigit(oneLine[0]))
{

if (source.eof())
{
veri = false;
continue;
}

else
continue;

}

else
dataList.push_back(oneLine);


if (source.eof())
veri = false;
}

std::unique(dataList.begin(), dataList.end());

/*
std::deque::iterator beginITER = dataList.begin();

while (beginITER != dataList.end())
{
output << *beginITER;
beginITER++;
}
*/

std:stream_iterator outFile(output, "\n");
std::copy(dataList.begin(), dataList.end(), outFile);
dataList.clear();
}


VC++ gave these four warnings:


Compiling...mScanList.cppD:\C++\mScanList.cpp(81) : warning C4786: 'std::reverse_iterator,std::allocator >,std::allocator,std::allocator > > >::const_iterator,std::basic_string,std::allocator >,std::basic_string,std::allocator > const &,std::basic_string,std::allocator > const *,int>' : identifier was truncated to '255' characters in the debug informationD:\C++\mScanList.cpp(81) : warning C4786: 'std::reverse_iterator,std::allocator >,std::allocator,std::allocator > > >::iterator,std::basic_string,std::allocator >,std::basic_string,std::allocator > &,std::basic_string,std::allocator > *,int>' : identifier was truncated to '255' characters in the debug informationc:\program files\microsoft visual studio\vc98\include\deque(191) : warning C4786: 'std::deque,std::allocator >,std::allocator,std::allocator > > >::deque,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug informationc:\program files\microsoft visual studio\vc98\include\deque(208) : warning C4786: 'std::deque,std::allocator >,std::allocator,std::allocator > > >::~deque,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug informationmScanList.obj - 0 error(s), 4 warning(s)


VC++ outputs those warnings no even when I used the second technique which the compile ignored because of /* and */.

Does anyone know what it is talking about and how to elimate the warnings?

Thanks,
Kuphryn
 
Thanks guys.

I am having a problem with this forum's email notice. I have not received any email notice after someone reply to a thread. Thus I thought nobody replied.

Peter: Thanks. That code stopped the warnings.

euzeka: ahhh. Thanks! One more thing. Let sayd strTemp[0] = "a." That that automatically mean strTemp[1] = NULL?

earl: Hey, I do not quite see what you mean. Do you mean for example I should declear "std::" right after #include rather than using "std::" inside the function?

#include <iostream>
using std::cout;

rather than:

#include <iostream>

std::cout << "Hi!";

Kuphryn
 
I got the code working perfect. I use the vector contain, but the find() function first check to see if the data is already in the contain. If find() does not return end(), then the program inserts the data into the contain. It works great.

I have a question. I tried using the unique function with several containers including vector, deque and list. it does not seem to work unless the data inside the container is sorted.

I tried using the set container. Set automatically ignore clones, but it sorts the data inside the container by default. Is there a way to keep the data in its original order?

Kuphryn
 
euzeka: ahhh. Thanks! One more thing. Let sayd strTemp[0] = "a." That that automatically mean strTemp[1] = NULL?
No. Again, std::string does not have to be null terminated. Only the string returned by c_str() does. An implementation might decide to only add the NULL when c_str() is called to save on speed.

As for unique, look here. It says
Every time a consecutive group of duplicate elements appears in the range [first, last), the algorithm unique removes all but the first element. That is, unique returns an iterator new_last such that the range [first, new_last) contains no two consecutive elements that are duplicates. [1] The iterators in the range [new_last, last) are all still dereferenceable, but the elements that they point to are unspecified. Unique is stable, meaning that the relative order of elements that are not removed is unchanged.
It only works for duplicate elements that are next to each other (might or might not be sorted). It would work on something like 1, 1, 5, 5, 5, 2, 2.

If you want to keep your data in its original order... you might store a sequence ID along with the data in the set. Something along those lines. Or write a unique-like algorithm which doesn't require elements to be next to each other (will likely be O(N*N), or O(N*log(N)) at best).

[This message was edited by euzeka on December 04, 2001 at 12:49.]
 
Status
Not open for further replies.