🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by James Woodyatt Wed, 08 Apr 1992 00:08
Class templates and incomplete classes
#96
Author: James Woodyatt
Date: Wed, 08 Apr 1992 00:08
50 lines
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)'
Re: Class templates and incomplete classes
#97
Author: James Woodyatt
Date: Wed, 08 Apr 1992 02:57
32 lines
1218 bytes
In article <1992Apr8.000827.20812@wdl.loral.com>, bard@cutter.ssd.loral.com (James Woodyatt) writes:
|> int main()
|> {
|>     Foo f;
|> 
|>     f.foo();
|>     return 0;
|> }

I feel dumb. I should have written this:

int main()
{
    Foo<Bar> f& = foo;

    f.foo();
    return 0;
}

It doesn't change the substance of my question though.

Sorry about the confusion. I didn't notice the obsolete code because my
compiler was crashing on code upstream of this.


-- 
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)'
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads