Bug 21575 - definition member function of template class with nested class as return type
Summary: definition member function of template class with nested class as return type
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-14 21:22 UTC by Remko van der Vossen
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Remko van der Vossen 2005-05-14 21:22:17 UTC
The following code generates a compiler error on the function definition.

Tested with
  3.4.1 release
  3.4.3 release
  4.0.0 release

---

template<class T>
class foo {
public:
  typedef T foo2;

  foo2 bar();
};

template<class T>
foo<T>::foo2 foo<T>::bar() {
  return foo2();
}
Comment 1 Andrew Pinski 2005-05-14 21:24:05 UTC
Invalid, you need the typename keyword, like so:
template<class T>
class foo {
public:
  typedef T foo2;

  foo2 bar();
};

template<class T>
typename foo<T>::foo2 foo<T>::bar() {
  return foo2();
}