This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Template weirdness
- To: gcc at gcc dot gnu dot org
- Subject: Template weirdness
- From: Michael Vance <briareos at lokigames dot com>
- Date: Wed, 24 Nov 1999 08:45:06 -0800
I'm trying to figure out if this is a code problem or a compiler
problem. Attached is a small, distilled piece of sample code. The
output I get is:
[michael@namaste cpp]$ g++ -g inherit-template.cpp
inherit-template.cpp: In method `void
FDLB<NF::NF::LH<int>,float>::II<NF::NF::LH<int>, float>(class
NF::NF::LH<int> *)':
inherit-template.cpp:65: instantiated from here
inherit-template.cpp:51: no matching function for call to
`NF::NF::LH<int>::SK (NF::ks NF::Ks::*)'
inherit-template.cpp:32: candidates are:
NF::NF::LH<int>::SK<int>(NF::ks *)
This is with egcs-1.1.2, gcc-2.95.2, and CVS built the other day. All
on i686-pc-linux-gnu targets.
Any advice is appreciated.
m.
--
Programmer "I wrote a song about dental floss,
Loki Entertainment Software but did anyone's teeth get cleaner?"
http://lokigames.com/~briareos/ - Frank Zappa, re: the PMRC
#include <list>
#include <cstring>
class NF {
struct ks {
short l;
char b[256];
};
class K {
public:
ks k;
};
class Ks {
public:
ks k;
};
class MH {
};
template<class T>
class L : public std::list<T*> {
};
template<class T>
class LH : public L<T>, public K {
void SK( ks* kp ) {
k = kp;
};
};
};
template<class T, class NST>
class LB : public NF::MH, public NF::LH<T> {
};
template<class NFT, class NST>
class FDLB : public NF::Ks, public LB<NFT, NST> {
public:
FDLB( ) : Ks( ), LB<NFT, NST>( ) { };
void II( NFT* t ) {
t->SK( &(Ks::k) );
}
void foo( void ) {
memset( (void*) &( Ks::k ), 0, sizeof( NF::Ks ) );
}
};
int main( int argc, char* argv[] )
{
FDLB<NF::LH<int>,float> fdlb;
NF::LH<int> nflh;
fdlb.foo( );
fdlb.II( &nflh );
return 0;
}