Article View: comp.std.c++
Article #3447Re: Q: Generic Callbacks -- "Object->*func(...)"
From: Bjorn Fahller
Date: Mon, 19 Feb 1996 04:30
Date: Mon, 19 Feb 1996 04:30
38 lines
2391 bytes
2391 bytes
David Byrden <100101.2547@compuserve.com> wrote:
>
> >> I'd like to be able to call "DoIt" with any type of object and a
> >> pointer to any of that object's member functions that match the
> >> 'parmlist'
>
> In the C++ Report, February 1995, Richard Hickey suggested a library of
> universal callback functors which would encapsulate both an object
> reference and a pointer to a member function of that object.
>
> The caller, and the provider of the callback, would not have to share
> any type information other than the callback library itself.
Unfortunately the implementation is all but clean, and depends
heavily on the compiler used. Internally, everything is
casted to void*. When I tried the implementation on Sun SparcWorks,
it failed, since pointer to member functions cannot be casted
to void* without severe loss of precision (they're twise
as long as void*.)
The ideas are still usable, though. Those who are interested
can e-mail me for a simple example (not quite as slick as the
original, but not compiler dependant since it doesn't use
ugly casts.)
_
/Bjorn.
--
Bjorn Fahller Tel: +46 8 4220898 /
NA/EBC/F/SNM/T ------------------- ^
Ericsson Business Networks AB / |
S-131 89 Stockholm/SWEDEN / Clever quote goes right here --+
---
[ To submit articles: Try just posting with your news-reader.
If that fails, use mailto:std-c++@ncar.ucar.edu
FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID:
<312495AD.757A@ebc.ericsson.se>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backReferences:
<4fti32$p3p@bcarh8ab.bnr.ca> <4g0csh$dq5@news.bridge.net>Show Full Headers
Complete Article Headers
From: Bjorn Fahller <ebcbear@ebc.ericsson.se> Message-ID: <312495AD.757A@ebc.ericsson.se> X-Original-Date: Fri, 16 Feb 1996 15:33:17 +0100 Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back Date: 19 Feb 96 04:30:21 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Return-Path: <daemon@meeker.UCAR.EDU> Organization: Ericsson Business Networks AB X-Mailer: Mozilla 2.0 (X11; I; HP-UX A.09.05 9000/735) Subject: Re: Q: Generic Callbacks -- "Object->*func(...)" References: <4fti32$p3p@bcarh8ab.bnr.ca> <4g0csh$dq5@news.bridge.net> X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMSf9FeEDnX0m9pzZAQEhpgGAltpe27z7iGrILhZaGbDdC2KS0nvDJfrN DP4ejUeE5uCJJQY4MZ6Do+IX6c3A6Q/G =s+0z