This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: libstdc++/1732


The following reply was made to PR libstdc++/1732; it has been noted by GNATS.

From: Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: libstdc++/1732 
Date: Tue, 23 Jan 2001 20:01:38 +0100 (CET)

 I am not sure if the parentheses are extraneous. For if I add an
 output routine via the copy function and an ostream_iterator, the code
 does not compile, which is really strange. The compiler message claims
 that the class menge does not contain an iterator begin or end of the
 correct type. 
 
 Surprisingly, if I initialise the container with the help of the copy
 function and an inserter (change the #if 1 to #if 0) the code compiles
 and works as expected. Could you please elaborate why this code does
 not compile for #if 1. Are there problems with iterators?
 
 Thanks for your reply.
 Peter Schmid
 
 tv.C
 #include <iostream>
 #include <algorithm>
 #include <vector>
 using namespace std;
 
 int main()
 {
     
 #if 1
     vector<int> menge(istream_iterator<int>(cin),
                         istream_iterator<int>());
 #else
     vector<int> menge;
     copy (istream_iterator<int>(cin),
           istream_iterator<int>(),
           inserter(menge,menge.end()));
 #endif
     
     copy (menge.begin(), menge.end(),
           ostream_iterator<int>(cout, "\n"));
 }
 
 #if 1
 g++ -o tv tv.C -W -Wall
 tv.C: In function `int main()':
 tv.C:19: request for member `begin' in `menge', which is of non-aggregate type 
    `std::vector<int, std::allocator<int> > ()(std::istream_iterator<int, 
    ptrdiff_t>, std::istream_iterator<int, ptrdiff_t> (*)())'
 tv.C:19: request for member `end' in `menge', which is of non-aggregate type 
    `std::vector<int, std::allocator<int> > ()(std::istream_iterator<int, 
    ptrdiff_t>, std::istream_iterator<int, ptrdiff_t> (*)())'
 
 #if 0
 g++ -o tv tv.C -W -Wall
 
 peter@kiste:~ > ./tv
 1 2 3
 1
 2
 3
 
 
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]