public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/9344: in template, typedef for reference return type cannot be used
@ 2003-01-16 22:26 florian.kirsch
  0 siblings, 0 replies; 3+ messages in thread
From: florian.kirsch @ 2003-01-16 22:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 818 bytes --]

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

From: florian.kirsch@gmx.net
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org
Cc:  
Subject: Re: c++/9344: in template, typedef for reference return type cannot be used
Date: Thu, 16 Jan 2003 23:16:49 +0100 (MET)

 Hm, i just found out that my posted code is probably incorrect,
 and that my problem can be solved by repeating the typename 
 in the function declaration. I am not sure what the standard says
 here, though.
 
 template<typename T> class Container {
 public:
     typedef typename std::vector<T>::reference ref;
     typename Container<T>::ref foo() { }                 // works
 };
 
 Florian
 
 -- 
 +++ GMX - Mail, Messaging & more  http://www.gmx.net +++
 NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/9344: in template, typedef for reference return type cannot be used
@ 2003-01-16 22:28 bangerth
  0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2003-01-16 22:28 UTC (permalink / raw)
  To: florian.kirsch, gcc-bugs, gcc-prs, nobody

Synopsis: in template, typedef for reference return type cannot be used

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Thu Jan 16 14:27:58 2003
State-Changed-Why:
    You need to use the "typename" keyword here as well:
      typename Container<T>::ref foo1() { }
    or omit the qualification:
      ref foo1() { }

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9344


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c++/9344: in template, typedef for reference return type cannot be used
@ 2003-01-16 21:16 florian.kirsch
  0 siblings, 0 replies; 3+ messages in thread
From: florian.kirsch @ 2003-01-16 21:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9344
>Category:       c++
>Synopsis:       in template, typedef for reference return type cannot be used
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 16 13:16:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Florian Kirsch
>Release:        gcc version 3.4 20030115 (experimental)
>Organization:
>Environment:
Linux darkstar 2.4.14 #6 Tue Nov 6 17:10:23 MET 2001 i586 unknown

>Description:
The following code is stripped down from some meaningful code 
(VRS, www.vrs3d.org). It compiles with gcc-3.0.4 and gcc-3.2.1. 
With gcc head, I get the following error in function foo1():

kirsch@darkstar:/home/kirsch/gcctest > g++ container.cpp -o container.o
container.cpp:6: error: expected function-definition



#include <vector>

template<typename T> class Container {
public:
    typedef typename std::vector<T>::reference ref;
    Container<T>::ref foo1() { }                    // error

    typename std::vector<T>::reference foo2() { }   // ok
};

int main(int argc, char** argv) {
    Container<int>* c = new Container<int>;
    return 0;
}



Best regards, 

Florian
>How-To-Repeat:
simply compile the above code
>Fix:
as a workaround, do not use a typedef for the return type,
as in function foo2().
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-16 22:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-16 22:26 c++/9344: in template, typedef for reference return type cannot be used florian.kirsch
  -- strict thread matches above, loose matches on Subject: below --
2003-01-16 22:28 bangerth
2003-01-16 21:16 florian.kirsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).