Thread View: comp.std.c++
2 messages
2 total messages
Started by Jorma Tolonen
Wed, 23 Aug 1995 20:11
void as template argument
Author: Jorma Tolonen
Date: Wed, 23 Aug 1995 20:11
Date: Wed, 23 Aug 1995 20:11
29 lines
1340 bytes
1340 bytes
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. ]
Re: void as template argument
Author: Fergus Henderson
Date: Wed, 06 Sep 1995 17:24
Date: Wed, 06 Sep 1995 17:24
31 lines
1851 bytes
1851 bytes
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. ]
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