This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21835] New: compilation of CRTP fails if the ABC is after template
- From: "maierkom at rcs dot ei dot tum dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 May 2005 08:40:17 -0000
- Subject: [Bug c++/21835] New: compilation of CRTP fails if the ABC is after template
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
the compilation of a curious recuring template fails if the base class for the
instantiation of the curious recuring template pattern (CRTP) is defined after
the template but before its instantiation.
The following code demonstrates the problem. If uncommenting the outcommented
section and commenting out the latter appearance of the same code, it compiles
successfully.
#include <iostream>
using namespace std;
/*
struct Client
{
void visit(const class A &a)
{ cout << "Client::visit(const A &)" << endl; }
};
struct MYABC
{
virtual void runVisitor(class Client &) const = 0;
};
*/
template <class Derived, class ABC>
struct Door : public ABC
{
Door()
: ABC()
{ }
void runVisitor(class Client &) const;
};
template <class Derived, class ABC>
void Door<Derived,ABC>::runVisitor(class Client &c) const
{ c.visit(static_cast<const Derived &>(*this)); }
struct Client
{
void visit(const class A &a)
{ cout << "Client::visit(const A &)" << endl; }
};
struct MYABC
{
virtual void runVisitor(class Client &) const = 0;
};
struct A : public Door<A,MYABC>
{
};
--
Summary: compilation of CRTP fails if the ABC is after template
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: maierkom at rcs dot ei dot tum dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: sparc-sun-solaris2.8
GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21835