|
From: Tommy N. <pn...@vi...> - 2002-09-26 19:42:19
|
I am having problems compiling
the code below with Mingw32 (GCC v3.2).
Can you please help me with this?
Thanks,
Tommy.
--------------------------------------------
#include<iostream>
#include<vector>
using namespace std;
struct Data {
vector<string> x;
};
int main(void) {
vector<Data> vec(10);
vec[0].x.insert(&vec[0].x[0], "data");
cout << vec[0].x[0] << endl;
return 0;
}
--------------------------------------------
Here is the error message:
>Error Message:
>--------------
>
>insert.cc: In function `int main()':
>insert.cc:15: no matching function for call to `std::vector<std::string,
> std::allocator<std::string> >::insert(std::string*, const char[5])'
>F:/mingw2/include/c++/3.2/bits/stl_vector.h:540: candidates are:
> __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
> std::vector<_Tp, _Alloc>::insert(__gnu_cxx::__normal_iterator<_Tp*,
> std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = std::string, _Alloc =
> std::allocator<std::string>]
>F:/mingw2/include/c++/3.2/bits/stl_vector.h:564:
> __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
> std::vector<_Tp, _Alloc>::insert(__gnu_cxx::__normal_iterator<_Tp*,
> std::vector<_Tp, _Alloc> >) [with _Tp = std::string, _Alloc =
> std::allocator<std::string>]
>F:/mingw2/include/c++/3.2/bits/stl_vector.h:613: void
> std::vector<_Tp, _Alloc>::insert(__gnu_cxx::__normal_iterator<_Tp*,
> std::vector<_Tp, _Alloc> >, unsigned int, const _Tp&) [with _Tp =
> std::string, _Alloc = std::allo
-----Original Message-----
From: Tommy Ngo [mailto:pn...@vi...]
Sent: Thursday, September 26, 2002 12:18 PM
To: 'Bjarne Stroustrup'
Cc: pn...@vi...
Subject: RE: Compiling Problems with insert().
Thank you. I will forward the
problem to the GNU GCC Team,
and have them look into this
problem.
I switched back to GCC v2.95.3, and
the problem went away.
Tommy.
-----Original Message-----
From: Bjarne Stroustrup [mailto:bs...@re...]
Sent: Thursday, September 26, 2002 11:59 AM
To: pn...@vi...
Subject: Re: Compiling Problems with insert().
Correction: The compiler I used wasn't GCC 3.2. With GCC 3.2 I get the same
error as you do. With EDG on SGI, your program compiles and runs as expected,
giving the output "data"
>Delivered-To: bs...@re...
>X-Authentication-Warning: mail-red.research.att.com: postfixfilter set sender
to pn...@vi... using -f
>From: "Tommy Ngo" <pn...@vi...>
>To: <bs...@re...>
>Cc: <pn...@vi...>
>Subject: Compiling Problems with insert().
>Date: Thu, 26 Sep 2002 10:54:45 -0700
>MIME-Version: 1.0
>Content-Transfer-Encoding: 7bit
>X-Priority: 3 (Normal)
>X-MSMail-Priority: Normal
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>Importance: Normal
>X-Spam-Status: No, hits=0.0 required=5.0 tests= version=2.20
>X-Spam-Level:
>
>Hi, Dr. Stroustrup.
>
>
>I am trying to compile the code
>with Mingw32 (gcc 3.2), and it
>is giving me problems. I don't know
>what is the problem. Can you
>please take a look at the code
>to see what I am doing is correct.
>
>
>Thank you very much,
>
>Tommy Ngo.
>
>
>-----------------------------------------------------------------
>#include<iostream>
>#include<vector>
>
>using namespace std;
>
>struct Data {
> vector<string> x;
>};
>
>
>int main(void) {
>
> vector<Data> vec(10);
>
> vec[0].x.insert(&vec[0].x[0], "data");
>
> cout << vec[0].x[0] << endl;
>
> return 0;
>
>}
>
>
>/*
>
>Error Message:
>--------------
>
>insert.cc: In function `int main()':
>insert.cc:15: no matching function for call to `std::vector<std::string,
> std::allocator<std::string> >::insert(std::string*, const char[5])'
>F:/mingw2/include/c++/3.2/bits/stl_vector.h:540: candidates are:
> __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
> std::vector<_Tp, _Alloc>::insert(__gnu_cxx::__normal_iterator<_Tp*,
> std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = std::string, _Alloc =
> std::allocator<std::string>]
>F:/mingw2/include/c++/3.2/bits/stl_vector.h:564:
> __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
> std::vector<_Tp, _Alloc>::insert(__gnu_cxx::__normal_iterator<_Tp*,
> std::vector<_Tp, _Alloc> >) [with _Tp = std::string, _Alloc =
> std::allocator<std::string>]
>F:/mingw2/include/c++/3.2/bits/stl_vector.h:613: void
> std::vector<_Tp, _Alloc>::insert(__gnu_cxx::__normal_iterator<_Tp*,
> std::vector<_Tp, _Alloc> >, unsigned int, const _Tp&) [with _Tp =
> std::string, _Alloc = std::allocator<std::string>]
>
>*/
>
- Bjarne
Bjarne Stroustrup, http://www.research.att.com/~bs
|