[Bug c++/30053] New: Template spezialisation error

Andreas at Familie-Pfeil dot com gcc-bugzilla@gcc.gnu.org
Sat Dec 2 18:06:00 GMT 2006


// I am using: i686-apple-darwin8-g++-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc.
build 5363)
// 
// compile with: g++ template_demo.c++
// yields:
// template_demo.c++:30: error: template-id 'outer<>' for 'void A<int>::outer()
const' does not match any template declaration
// template_demo.c++:30: error: invalid function declaration

// Name: Andreas Pfeil, Email: Andreas@Familie-Pfeil.com

#include <iostream>
using namespace std;

// General Version works...
template< class Value > class A {
public:
  void inner() const { cout << "<Value>inner" << endl; }
  void outer() const;
};
template< class Value > void A<Value>::outer() const { cout << "<Value>outer"
<< endl; }


// while specialized version complains.
template<> class A < int > {
public:
  void inner() const { cout << "<int>inner" << endl; }
  void outer() const;
};

// Problem line - compiler error or my error?
template<> void A<int>::outer() const { cout << "<int>outer" << endl; }

int main( int argc, char** argv ) {
  A<int>  a;
  a.inner();
  a.outer(); // How to make this line work???
  return 0;
}


-- 
           Summary: Template spezialisation error
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Andreas at Familie-Pfeil dot com
 GCC build triplet: i686-apple-darwin8
  GCC host triplet: i686-apple-darwin8
GCC target triplet: i686-apple-darwin8


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30053



More information about the Gcc-bugs mailing list