Here are the errors from my Dev-c compiler
////////////////////////////////////////////////////////////////////////////
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
g++.exe -c Tests.cpp -o Tests.o
-I"C:/Dev-Cpp/include/c++/3.3.1"
-I"C:/Dev-Cpp/include/c++/3.3.1/mingw32"
-I"C:/Dev-Cpp/include/c++/3.3.1/backward"
-I"C:/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include"
-I"C:/Dev-Cpp/include"
C:/Dev-Cpp/include/c++/3.3.1/bits/stl_pair.h: In constructor
`std::pair<_T1,
_T2>::pair(const std::pair<_U1, _U2>&) [with _U1 =
__gnu_cxx::__normal_iterator<std::string*, std::vector<std::string,
std::allocator<std::string> > >, _U2 =
__gnu_cxx::__normal_iterator<std::string*, std::vector<std::string,
std::allocator<std::string> > >, _T1 = std::string*, _T2 =
std::string*]':
Tests.cpp:59: instantiated from here
C:/Dev-Cpp/include/c++/3.3.1/bits/stl_pair.h:88: error: cannot convert
`const
__gnu_cxx::__normal_iterator<std::string*, std::vector<std::string,
std::allocator<std::string> > >' to `std::string*' in
initialization
C:/Dev-Cpp/include/c++/3.3.1/bits/stl_pair.h:88: error: cannot convert
`const
__gnu_cxx::__normal_iterator<std::string*, std::vector<std::string,
std::allocator<std::string> > >' to `std::string*' in
initialization
make.exe: *** [Tests.o] Error 1
Execution terminated
//////////////////////////////////////////////////////////////////////////////
And here is the code that emits those errors
// input strings and save them into vector of strings called str.
// begin to fetch from here.
while(std::getline(std::cin,hold)){
std::pair<std::string*, std::string*>
result=std::equal_range(str.begin(),str.end(), hold);
std::cout<<"the fresult is: "<<*result.first<<'\n';
std::cout<<"the lresult is: "<<*result.second<<'\n';
}
Using string pointers in pair<> like those above are not allowed right
?
I tested input string source code and compiler said it was correctly
witten but the above code gave errors..I am new to stl, Please
help..Thank you in advance. 1 4795
"Rhiner Dan" <st****@centralpets.com> wrote in message
news:f5**************************@posting.google.c om... Here are the errors from my Dev-c compiler
//////////////////////////////////////////////////////////////////////////// Building Makefile: "C:\Dev-Cpp\Makefile.win" Executing make... make.exe -f "C:\Dev-Cpp\Makefile.win" all g++.exe -c Tests.cpp -o Tests.o -I"C:/Dev-Cpp/include/c++/3.3.1" -I"C:/Dev-Cpp/include/c++/3.3.1/mingw32" -I"C:/Dev-Cpp/include/c++/3.3.1/backward" -I"C:/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"C:/Dev-Cpp/include" C:/Dev-Cpp/include/c++/3.3.1/bits/stl_pair.h: In constructor `std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&) [with _U1 = __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string,
std::allocator<std::string> > >, _U2 = __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >, _T1 = std::string*, _T2 = std::string*]': Tests.cpp:59: instantiated from here C:/Dev-Cpp/include/c++/3.3.1/bits/stl_pair.h:88: error: cannot convert `const __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >' to `std::string*' in initialization C:/Dev-Cpp/include/c++/3.3.1/bits/stl_pair.h:88: error: cannot convert `const __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >' to `std::string*' in initialization make.exe: *** [Tests.o] Error 1 Execution terminated //////////////////////////////////////////////////////////////////////////////
And here is the code that emits those errors // input strings and save them into vector of strings called str. // begin to fetch from here. while(std::getline(std::cin,hold)){ std::pair<std::string*, std::string*> result=std::equal_range(str.begin(),str.end(), hold); std::cout<<"the fresult is: "<<*result.first<<'\n'; std::cout<<"the lresult is: "<<*result.second<<'\n'; }
Using string pointers in pair<> like those above are not allowed right ? I tested input string source code and compiler said it was correctly witten but the above code gave errors..I am new to stl, Please help..Thank you in advance.
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
int main()
{
std::vector<std::string> str;
std::string hold;
while(std::getline(std::cin, hold))
{
std::pair<std::vector<std::string>::iterator,
std::vector<std::string>::iterator>
result(std::equal_range(str.begin(),
str.end(),
hold));
std::cout << "the fresult is: " << *result.first << '\n';
std::cout << "the lresult is: " << *result.second << '\n';
}
return 0;
}
-Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ramesh |
last post by:
Hello,
i am trying to run visual studio.NEt on my XP Laptop. i am getting an
exception.
thats says overflow/underflow error. i am unable to use any controls.
can u help please.
thanks
|
by: gf gf |
last post by:
I read that lower() is deprecated. Unfortunately, I
can't find the preferred way of lowercasing a string.
What is it?
Thanks
PS Please cc me on all responses.
|
by: Ron |
last post by:
I've written a screen saver which opens multiple copies on windows 98.
I'm trying to check the process list to determine if it is already running.
So far all the example win32 routines I've...
|
by: Rajesh Kumar Mallah |
last post by:
Hi,
We need to implement following logic efficiently.
SELECT * from some_table where ....
IF rows_matched = 1 THEN
use the single row that matched.
|
by: Martin Hampl |
last post by:
Hi,
I am using PostgreSQL 7.4, but I did have the same problem with the
last version.
I indexed the column word (defined as varchar(64)) using lower(word).
If I use the following query,...
|
by: Olivier Bellemare |
last post by:
I've tried to make a function that returns the middle of a string. For
example:
strmid("this is a text",6,4); would return "is a".
Here is my code:
char *strmid(char *texte, int depart,...
|
by: jimdscudder |
last post by:
I am using a file watcher to watch for files changing. My problem is: the
string file info returned is all LOWER CASE.
Below is the important part of the code?
Any suggestions?
using...
|
by: The Crow |
last post by:
i have a arraylist. say it contains integer values. i want to be able to
inform user, which indexes in the array contain same values. but there can
be N different values, and M different indexes...
|
by: dennis.richardson |
last post by:
Greetings all.
Here's a problem that's been driving me nuts for the last 48 hours.
I'm hoping that someone has come across this before.
I have a C# Application that reads a UDP broadcast...
|
by: jacob navia |
last post by:
Hi
We are rewriting the libc for the 64 bit version of lcc-win
and we have added a new field in the FILE structure:
char *FileName;
fopen() will save the file name and an accessor function
will...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
| |