George2
February 9th, 2003, 07:37 AM
Hi, everyone!
Here is my simple STL program, it is a spell-checker.
The program copy every word of text to output
that is not in the dictionary. I have added all the source
codes and error messages below. My IDE is VC6.0.
Source Codes:
--------
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <fstream>
using namespace std;
template <class bidirectional_iterator, class T>
class nonAssocFinder {
public:
nonAssocFinder(bidirectional_iterator begin,
bidirectional_iterator end) :
_begin(begin), _end(end) {}
bool operator() (const T& word) {
return binary_search(_begin, _end, word); }
private:
bidirectional_iterator _begin;
bidirectional_iterator _end;
};
void main()
{
typedef vector<string > dict_type;
ifstream dictFile("dict.txt");
ifstream wordsFile("words.txt");
dict_type dictionary;
copy (istream_iterator<string>(dictFile),
istream_iterator<string>(),
back_inserter(dictionary));
remove_copy_if (
istream_iterator<string>(wordsFile),
istream_iterator<string>(),
ostream_iterator<string>(cout, "\n"),
nonAssocFinder<dict_type::iterator,
dict_type::value_type>
(dictionary.begin(), dictionary.end()));
}
--------
Warning and error messages:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testDict\testDict.cpp(45) : warning C4786:
'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const
*,std::basic_string<char,std::char_traits<char>,std::all
ocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const
&,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255'
characters in the debug information
C:\Program Files\Microsoft Visual Studio\MyProjects\testDict\testDict.cpp(45) : warning C4786:
'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> >
*,std::basic_string<char,std::char_traits<char>,std::allocator
<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >
&,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters
in the debug information
c:\program files\microsoft visual studio\vc98\include\iterator(176) : error C2679: binary '>>' : no operator defined which
takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
(
or there is no acceptable conversion)
c:\program files\microsoft visual studio\vc98\include\iterator(176) : while compiling class-template member function
'void __thiscall std::istream_iterator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char>
>,char,struct std::char_traits<char> >::_Getval(void)'
--------
How to resolve the trouble?
Thanks in advance,
George
Here is my simple STL program, it is a spell-checker.
The program copy every word of text to output
that is not in the dictionary. I have added all the source
codes and error messages below. My IDE is VC6.0.
Source Codes:
--------
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <fstream>
using namespace std;
template <class bidirectional_iterator, class T>
class nonAssocFinder {
public:
nonAssocFinder(bidirectional_iterator begin,
bidirectional_iterator end) :
_begin(begin), _end(end) {}
bool operator() (const T& word) {
return binary_search(_begin, _end, word); }
private:
bidirectional_iterator _begin;
bidirectional_iterator _end;
};
void main()
{
typedef vector<string > dict_type;
ifstream dictFile("dict.txt");
ifstream wordsFile("words.txt");
dict_type dictionary;
copy (istream_iterator<string>(dictFile),
istream_iterator<string>(),
back_inserter(dictionary));
remove_copy_if (
istream_iterator<string>(wordsFile),
istream_iterator<string>(),
ostream_iterator<string>(cout, "\n"),
nonAssocFinder<dict_type::iterator,
dict_type::value_type>
(dictionary.begin(), dictionary.end()));
}
--------
Warning and error messages:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testDict\testDict.cpp(45) : warning C4786:
'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const
*,std::basic_string<char,std::char_traits<char>,std::all
ocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const
&,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255'
characters in the debug information
C:\Program Files\Microsoft Visual Studio\MyProjects\testDict\testDict.cpp(45) : warning C4786:
'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> >
*,std::basic_string<char,std::char_traits<char>,std::allocator
<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >
&,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters
in the debug information
c:\program files\microsoft visual studio\vc98\include\iterator(176) : error C2679: binary '>>' : no operator defined which
takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
(
or there is no acceptable conversion)
c:\program files\microsoft visual studio\vc98\include\iterator(176) : while compiling class-template member function
'void __thiscall std::istream_iterator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char>
>,char,struct std::char_traits<char> >::_Getval(void)'
--------
How to resolve the trouble?
Thanks in advance,
George