Topic: void as template argument


Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: 1995/09/06
Raw View
jorma.tolonen@mailbox.swipnet.se (Jorma Tolonen) writes:

>Is it OK to use void as an argument in a template-class.

Yes, so long as the template class doesn't use the type
argument in a way that is not allowed for `void', it should
be perfectly OK.

>I believe that a static member function had no guarantee that the linkage
>was the same as for C-functions. Is that still so, according to the upcoming
>standard?

Most definitely.  Static member functions must be allowed to have
different linkage conventions than C functions, because the compiler
must support overloaded static member functions.  All existing C++
compilers that I know of use a different linkage convention for
static member functions than they do for extern "C" functions.

I suspect the question you were really trying to ask was about the
*calling convention* of static member functions, not their linkage.
I'm afraid that question is yet to be resolved.

--
Fergus Henderson             |  #define x t=a[i],a[i]=a[m],a[m]=t
                             |  char a[]=" 12345678";main(m,i,j,t){for(i=m;i<
fjh@cs.mu.oz.au              |  9;x,i++)for(x,j=m;--j?(t=a[m-j]-a[m])-j&&t+j:
http://www.cs.mu.oz.au/~fjh  |  main(m+1)*0;);m-9||puts(a+1);} /* 8 queens */
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]





Author: jorma.tolonen@mailbox.swipnet.se (Jorma Tolonen)
Date: 1995/08/23
Raw View
Is it OK to use void as an argument in a template-class. Example:

template <class Pointer>
class Base
{
public:
   Base() { }
   virtual ~Base() { }
   virtual void DoIt() = 0;
   static void func(Pointer* client_data) { ((Base*)client_data)->DoIt(); }
};

Base<void> test;   // legal?

This is to be used in a general template class for callback functionality.

Another question while I am at it:

I believe that a static member function had no guarantee that the linkage
was the same as for C-functions. Is that still so, according to the upcoming
standard?

/jorma
jorma.tolonen@mailbox.swipnet.se


[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]