From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21828 invoked by alias); 24 Oct 2004 02:01:46 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 21792 invoked from network); 24 Oct 2004 02:01:44 -0000 Received: from unknown (HELO main.gmane.org) (80.91.229.2) by sourceware.org with SMTP; 24 Oct 2004 02:01:44 -0000 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CLXhY-0007DW-00 for ; Sun, 24 Oct 2004 04:01:44 +0200 Received: from evrtwa1-ar6-4-11-123-045.dsl-verizon.net ([4.11.123.45]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 24 Oct 2004 04:01:44 +0200 Received: from jeff.holle by evrtwa1-ar6-4-11-123-045.dsl-verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 24 Oct 2004 04:01:44 +0200 To: gcc-help@gcc.gnu.org From: Jeffrey Holle Subject: Re: Confusing template error... Date: Sun, 24 Oct 2004 02:01:00 -0000 Message-ID: References: <363801FFD7B74240A329CEC3F7FE4CC4030963B4@ntxboimbx07.micron.com> Reply-To: jeff.holle@verizon.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: evrtwa1-ar6-4-11-123-045.dsl-verizon.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115 In-Reply-To: X-SW-Source: 2004-10/txt/msg00179.txt.bz2 If I were trying this, I'd follow the "note" suggestion in gcc's error message. That is: typename std::vector::const_iterator pos; James Urquhart wrote: > Unfortunatly, the solution does not seem to work. > > "std::vector::const_iterator pos;" > Gives me the errors: > error: template argument 1 is invalid > error: template argument 2 is invalid > error: expected `;' before '::' token > > I also tried doing : > "typename std::vector::const_iterator pos;" > As someone else suggested, but that gives me the same errors as previously. > > On Mon, 18 Oct 2004 10:33:09 -0600, lrtaylor@micron.com > wrote: > >>Try this: >> >> std::vector::const_iterator pos; >> >>Thanks, >>Lyle >> >> >> >> >>-----Original Message----- >>From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On >>Behalf Of James Urquhart >>Sent: Saturday, October 16, 2004 4:07 PM >>To: gcc-help@gcc.gnu.org >>Subject: Confusing template error... >> >>Hi there, >> >>I was wondering if anyone has encountered this rather bizzare syntax >>error before. >> >>The code is as follows (NOTE: this is inside a class { }) : >> >> template >> inline OutputStream & operator << (OutputStream & out, const >>std::vector &v) >> { >> std::vector::const_iterator pos; >> pos = v.begin() ; >> while (pos != v.end()) >> { >> out << *pos++ ; >> } >> return out ; >> } >> >>(using the good ol' STL vector) >> >>in the "const_iterator" line, GCC claims : >>error: expected `;' before "pos" >> >>in addition, every time the "<<" operator is used, GCC claims : >>error: dependent-name ` std::vector >> >>>::const_iterator' is parsed as a non-type, but instantiation yields a >> >>type >>note: say `typename std::vector >> >>>::const_iterator' if a type is meant >> >>(basically referring again to that line) >>If i remove the "pos;" at the end of the line, gcc seems to accept it >>- but then i don't have a "pos" variable, which is pretty useless. >> >>Now onto the next problem... >> >>With this code (again, in a class { }) : >> >>template >> inline InputStream & operator >> (InputStream & in, std::vector >>&v) >> { >> std::vector::iterator pos = v.begin() ; >> while (pos != v.end()) >> { >> in >> *pos++ ; >> } >> return in ; >> } >> >>Every time ">>" is used on this class, GCC claims on the "iterator" >>line: >>error: dependent-name ` std::vector >> >>>::iterator' is parsed as a non-type, but instantiation yields a type >> >>note: say `typename std::vector >> >>>::iterator' if a type is meant. >> >>And the gcc variant : >>gcc version 3.4.2 (Gentoo Linux 3.4.2-r2, ssp-3.4.1-1, pie-8.7.6.5) >> >>Thanks for any help. >> > >