Article View: comp.std.c++
Article #96Class templates and incomplete classes
From: James Woodyatt
Date: Wed, 08 Apr 1992 00:08
Date: Wed, 08 Apr 1992 00:08
50 lines
1475 bytes
1475 bytes
My compiler (GCC-2.1) complains about the following code by going down
on a segmentation fault (which I figure is enough cause to report it as
a bug), but I have reservations about the validity of the code.
Is this legal? I'm trying to declare a template class with an incomplete
class as the template's parameter.
-------------------------------------------------------------------------
template<class T>
class Foo
{
Method method;
public:
typedef void (T::*Method)();
Foo(Method m) : method(m) { }
void foo() { (*method)(); }
};
class Bar
{
public:
static Foo<Bar> foo; // Instantiate a template class on an incomplete class
void alpha() { }
void beta() { }
};
Bar::foo(&Bar::alpha);
int main()
{
Foo f;
f.foo();
return 0;
}
--
James Woodyatt Space Systems/Loral Palo Alto, CA bard@cutter.ssd.loral.com
``And when he dreamed his ears drooled thirty weight engine oil
He took personality tests and stapled them to his lower lip''
--Stan Ridgway,
`Jack Talked (Like A Man On Fire)'
Technical Details
Message-ID:
<1992Apr8.000827.20812@wdl.loral.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!mips!wdl1!cutter!bardShow Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!mips!wdl1!cutter!bard From: bard@cutter.ssd.loral.com (James Woodyatt) Subject: Class templates and incomplete classes Message-ID: <1992Apr8.000827.20812@wdl.loral.com> Sender: bard@cutter (James Woodyatt) Organization: Space Systems/Loral Date: Wed, 8 Apr 1992 00:08:27 GMT