Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #9212
| From | "Default User" <defaultuserbr@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Fun with member-function pointers |
| Date | 2011-08-22 19:06 -0500 |
| Message-ID | <9bg98kFlfoU1@mid.individual.net> (permalink) |
| References | <9bg0ojFsapU1@mid.individual.net> <j2uoi5$jgn$1@dont-email.me> |
"Victor Bazarov" <v.bazarov@comcast.invalid> wrote in message
news:j2uoi5$jgn$1@dont-email.me...
> On 8/22/2011 5:41 PM, Default User wrote:
> I'd probably tried to change this to
>
> CALL_HANDLER(o, p, args) ((o).*(p)) args
What! You dare question the CLC++ FAQ list where I copied that from? I'll
look at it.
> (see below for the use).
>
>>
>> class tbase
>> {
>> public:
>> tbase() : p(0)
>
> Perhaps (a) it shouldn't be public (do you intend to instantiate this?
> It's an ABC, isn't it?) and (b) it should have the argument to init the
> 'p' with (defautl to 0):
This was just a quicky demo. So I didn't bother with some of that sort of
thing. I'll check the "real" code though.
>> class test : tbase
>> {
>> public:
>> test()
>> {
>> p = static_cast<HandlerPtr>(&test::f);
>
> Shouldn't you use the initializer list instead of the assignment? See
> FAQ.
For this case, sure. But the actual code will be putting them in a std::map
with the op codes as indexes.
> There is no real problem yet. Now imagine that somebody thinks of
> deriving from your 'test' and providing their own handler? How would they
> do it? Or can that never happen?
I guess I'm not sure what the specific problem you're concerned about. I
fear my quicky proof-of-concept demo might have been too sketchy.
> Another possible solution is to actually have a pointer to function
> instead of pointer to member, and cast 'this' to the specific class, which
> is usually "safer", I think. Not that I know much about that...
I don't think so. One goal is to push a lot of behavior down to the base
class. I can make the handler map and the handler calling function go down
there. Then the derived class will populate the map with its specific
handler for each op code. The upper level modules just call with the op
codes and data.
I'll look to see if I can rework my demo tomorrow to make it a bit more like
the real use case.
Brian
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Fun with member-function pointers "Default User" <defaultuserbr@yahoo.com> - 2011-08-22 16:41 -0500
Re: Fun with member-function pointers Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-22 19:25 -0400
Re: Fun with member-function pointers "Default User" <defaultuserbr@yahoo.com> - 2011-08-22 19:06 -0500
Re: Fun with member-function pointers Juha Nieminen <nospam@thanks.invalid> - 2011-08-23 07:09 +0000
Re: Fun with member-function pointers Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-23 08:04 -0400
Re: Fun with member-function pointers Juha Nieminen <nospam@thanks.invalid> - 2011-08-23 13:34 +0000
Re: Fun with member-function pointers Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-23 13:02 -0400
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-23 19:12 -0700
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-23 18:51 -0700
Re: Fun with member-function pointers Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-08-23 09:07 +0200
Re: Fun with member-function pointers Juha Nieminen <nospam@thanks.invalid> - 2011-08-23 10:09 +0000
Re: Fun with member-function pointers Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-08-23 15:04 +0200
Re: Fun with member-function pointers "Default User" <defaultuserbr@yahoo.com> - 2011-08-23 10:36 -0500
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-23 18:46 -0700
Re: Fun with member-function pointers "Default User" <defaultuserbr@yahoo.com> - 2011-08-24 09:33 -0500
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-24 08:32 -0700
Re: Fun with member-function pointers "Default User" <defaultuserbr@yahoo.com> - 2011-08-24 11:15 -0500
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-24 09:30 -0700
Re: Fun with member-function pointers Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-08-24 12:27 +0200
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-24 06:46 -0700
Re: Fun with member-function pointers Marcel Müller <news.5.maazl@spamgourmet.org> - 2011-08-24 18:57 +0200
Re: Fun with member-function pointers Paul <pchristor@yahoo.co.uk> - 2011-08-24 13:08 -0700
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-24 13:44 -0700
Re: Fun with member-function pointers Paul <pchristor@yahoo.co.uk> - 2011-08-25 04:23 -0700
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-25 07:31 -0700
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-25 08:21 -0700
Re: Fun with member-function pointers Paul <pchristor@yahoo.co.uk> - 2011-08-25 10:50 -0700
Re: Fun with member-function pointers Leigh Johnston <leigh@i42.co.uk> - 2011-08-25 13:57 +0100
Re: Fun with member-function pointers Leigh Johnston <leigh@i42.co.uk> - 2011-08-25 14:08 +0100
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-25 07:32 -0700
Re: Fun with member-function pointers Leigh Johnston <leigh@i42.co.uk> - 2011-08-25 15:45 +0100
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-25 07:48 -0700
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-23 18:43 -0700
Re: Fun with member-function pointers Paul <pchristor@yahoo.co.uk> - 2011-08-23 03:49 -0700
Re: Fun with member-function pointers Paul <pchristor@yahoo.co.uk> - 2011-08-23 06:44 -0700
Re: Fun with member-function pointers Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-23 18:28 -0700
Re: Fun with member-function pointers Jeff Flinn <TriumphSprint2000@hotmail.com> - 2011-08-25 11:29 -0400
csiph-web