The dreaded question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phlip

    #16
    Re: The dreaded question

    caustik wrote:
    [color=blue]
    > I don't care if its bad C++, I really dont. I need to convert from
    > a member function pointer to a "void*" with zero computational
    > overhead.[/color]

    Why?

    Answering why might lead us to a suggestion that's good for your code.

    (BTW the answer is: put the member function pointer into a structure, take
    the address of the structure, and cast away. Good luck not crashing.)

    --
    Phlip




    Comment

    • Ron Natalie

      #17
      Re: The dreaded question


      "caustik" <caustik@nospam .com> wrote in message news:bdvnpi$hg8 $1@eeyore.INS.c wru.edu...[color=blue]
      > P.S. This works *Pefectly* (on my x86/win32 system, which is all i'm
      > targetting) :
      >[/color]
      How can it work perfectly? On VC++ the sizeof(MPT) is some where
      between 2 and 4 times the sizeof (void*)?


      Comment

      • Steve Coleman

        #18
        Re: Troll Alert: The dreaded question

        E. Robert Tisdale wrote:
        [color=blue]
        > I was simply expressing my opinion.
        > I look for the typical signs:
        >
        > 1. a troll handle
        > caustik,
        > 2. a forged or disposable email account
        > nospam.com,[/color]

        Well, they can try to anyway... ;-)

        NNTP-Posting-Host: sandiego.divxne tworks.com
        X-Trace: eeyore.INS.cwru .edu 1057183867 12825
        207.67.92.110 (2 Jul 2003 22:11:07 GMT)
        X-Complaints-To: abuse@po.cwru.e du
        NNTP-Posting-Date: 2 Jul 2003 22:11:07 GMT
        NNTP-Posting-User: acr10@sandiego. divxnetworks.co m

        In answer to the actual question...

        If performance is so much of an issue that it becomes socially
        acceptable to insult those that might try to help (even before asking
        the question), then what's wrong with just coding an ASM var push/pop or
        register move and be done with it? *That* will convert most anything! ..
        and also ignore all language usage restrictions (aka. protections) in
        the process. IMHO one beauty in the C++ language is that it _has_ these
        restrictions, and all for good reason! To prevent someone from abusing
        the usage of known types in a manner which is undefined or incorrect.

        On the other hand my glass is always half full, and given the latest
        description of the problem from the original poster perhaps we should
        discuss the correct manner to address his issues rather than getting so
        wrapped up in the emotionally charged aspects of it. Do we have enough
        to go on for a C++ design discussion here? Can anyone out there suggest
        a *better solution*[tm] USING the C++ language instead of trying to
        fight against it(e.g. unions of pointers)? I'm sure that others out
        there who are learning C++ might benefit from a discussion of C++ design
        rather than a food fight (lol).





        Comment

        • Default User

          #19
          Re: The dreaded question



          Alexander Terekhov wrote:[color=blue]
          >
          > Default User wrote:
          > [...][color=green]
          > > Yeah . . . I going to need you to go into my killfile. Yeah . . . move
          > > all the way to the back. Thanks, that'll be great.[/color]
          >
          > I'm just curious: how BIG is your killfile?[/color]

          Don't worry Al, there's a place for you if you really need it.



          Brian Rodenborn

          Comment

          • Default User

            #20
            Re: Troll Alert: The dreaded question



            "E. Robert Tisdale" wrote:
            [color=blue]
            > There is seldom a good reason why a legitimate post
            > to a technical newsgroup like comp.lang.c++
            > should evoke a strong emotional response in any subscriber.
            > If it does, you should suspect a troll.[/color]


            Well, I feel that way about many of your posts, especially on
            comp.lang.c.




            Brian Rodenborn

            Comment

            • Alexander Terekhov

              #21
              Re: The dreaded question


              Default User wrote:[color=blue]
              >
              > Alexander Terekhov wrote:[color=green]
              > >
              > > Default User wrote:
              > > [...][color=darkred]
              > > > Yeah . . . I going to need you to go into my killfile. Yeah . . . move
              > > > all the way to the back. Thanks, that'll be great.[/color]
              > >
              > > I'm just curious: how BIG is your killfile?[/color]
              >
              > Don't worry Al, there's a place for you if you really need it.[/color]

              For free?

              regards,
              alexander.

              Comment

              • Jeff Rosenfeld

                #22
                Re: The dreaded question

                template <class T> inline void* MFPtoFP (T p) { return
                reinterpret_cas t<void*>(p); }

                or maybe even do away with type-foo like so:

                #define MFPtoFP(p) reinterpret_cas t<void*>(p)

                or some such variant seems to be what you want. Just make sure only to
                instantiate it with pointer types. You could be losing information, though,
                because pointers to member functions (or even to normal functions) can be
                larger than pointers to data.

                - Jeff.

                "caustik" <caustik@nospam .com> wrote in message
                news:bdvl9r$cgp $1@eeyore.INS.c wru.edu...[color=blue]
                > I don't care if its bad C++, I really dont. I need to convert from
                > a member function pointer to a "void*" with zero computational
                > overhead.
                >
                > I have the perfect way to do it right here, but i'm having troubles
                > because if the member function pointer i pass to the function is
                > not void with no params, I get a casting error.
                >
                > Any ideas how to do this?
                >
                > caustik
                >
                > // *************** *************** *************** *************** ******
                > // * Take THIS C++ !!
                > // *************** *************** *************** *************** ******
                > template <class BaseClass> inline void *MFPtoFP( void
                > (BaseClass::*pM emFunc)(void) )
                > {
                > union
                > {
                > void BaseClass::*pMe mFunc;
                > void *pFunc();
                > }
                > ThisConv;
                >
                > ThisConv.pFunc = pMemFunc;
                >
                > return ThisConv.pFunc;
                > }
                >
                >[/color]


                Comment

                • Alexander Terekhov

                  #23
                  Re: The dreaded question


                  Default User wrote:[color=blue]
                  >
                  > Alexander Terekhov wrote:[color=green]
                  > >
                  > > Default User wrote:[/color]
                  >[color=green][color=darkred]
                  > > > Don't worry Al, there's a place for you if you really need it.[/color]
                  > >
                  > > For free?[/color]
                  >
                  > I didn't charge you for the cheese, did I?[/color]

                  Cheese? I had to pay for garbage recycling.

                  regards,
                  alexander.

                  Comment

                  • Mike Wahler

                    #24
                    Re: Troll Alert: The dreaded question


                    E. Robert Tisdale <E.Robert.Tisda le@jpl.nasa.gov > wrote in message
                    news:3F036A8C.3 030306@jpl.nasa .gov...[color=blue]
                    > Something that calls itself caustik wrote:
                    >[color=green]
                    > > I don't care if its bad C++, I really don't. I need to convert from
                    > > a member function pointer to a "void*" with zero computational
                    > > overhead.
                    > >[/color][/color]

                    [color=blue][color=green]
                    > > I have the perfect way to do it[/color][/color]
                    ^^^^^

                    right here, but I'm having troubles
                    ^^^^^^^
                    [color=blue][color=green]
                    > > because if the member function pointer i pass to the function is
                    > > not void with no params, I get a casting error.[/color][/color]

                    Then is your way really 'perfect' after all?
                    [color=blue][color=green]
                    > >
                    > > Any ideas how to do this?[/color][/color]

                    How about your 'perfect' way?

                    -Mike



                    Comment

                    • Alexander Terekhov

                      #25
                      Re: Troll Alert: The dreaded question


                      Mike Wahler wrote: [...]

                      Whaler, you did it much better last year. Gee, that was fun...
                      can we do this again?



                      **********
                      Just a quick note to wish all my American friends and
                      acquaintances here a happy, safe Independence Day.

                      Between the festivites, fireworks, backyard barbeques, etc.,,
                      please take a moment to acknowledge the extraordinary integrity,
                      courage, and achievements of those who risked and gave their
                      lives so long ago in order to enable us to live as free people.

                      And to those of you from other various places around
                      the globe, a pleasant day and a happy, prosperous life
                      to you as well.

                      It's an honor and a pleasure to know and interact with
                      all of you.

                      -Mike

                      "I have never been able to conceive how any rational being could
                      propose happiness to himself from the exercise of power over
                      others." --Thomas Jefferson to A. L. C. Destutt de Tracy, 1811
                      **********

                      regards,
                      alexander.

                      P.S. Go and celebrate, chap. Don't waste your time here.

                      Comment

                      • Default User

                        #26
                        Re: The dreaded question



                        Alexander Terekhov wrote:[color=blue]
                        >
                        > Default User wrote:[/color]
                        [color=blue][color=green]
                        > > I didn't charge you for the cheese, did I?[/color]
                        >
                        > Cheese? I had to pay for garbage recycling.[/color]


                        What?! That was the finest genetically engineered Merican cheese food
                        substitute. All you had to do was unwrap it and place it on the ground,
                        it would have dissolved a tunnel straight down at least 500 feet (that's
                        like 29657.222 kizzometrics or whatever weird measurements you use over
                        there). No disposal costs were required at all.

                        You don't know much about cheese.




                        Brian Rodenborn

                        Comment

                        • Alexander Terekhov

                          #27
                          Re: The dreaded question


                          Default User wrote:[color=blue]
                          >
                          > Alexander Terekhov wrote:[color=green]
                          > >
                          > > Default User wrote:[/color]
                          >[color=green][color=darkred]
                          > > > I didn't charge you for the cheese, did I?[/color]
                          > >
                          > > Cheese? I had to pay for garbage recycling.[/color]
                          >
                          > What?! That was the finest genetically engineered Merican cheese food
                          > substitute. All you had to do was unwrap it and place it on the ground,
                          > it would have dissolved a tunnel straight down at least 500 feet (that's
                          > like 29657.222 kizzometrics or whatever weird measurements you use over
                          > there). No disposal costs were required at all.
                          >
                          > You don't know much about cheese.[/color]

                          I don't pretend to know much about it. I've just heard that
                          cheese was invented by a wandering slave who was carrying
                          milk across the Great American Desert in a saddlebag made
                          from an Alligator's stomach. American product.

                          regards,
                          alexander.

                          Comment

                          • JustBoo@BooHoo.gone

                            #28
                            Re: The dreaded question

                            On Mon, 7 Jul 2003 16:29:01 -0400, "Marduk"
                            <guill.lmNOSPAM @sympatico.ca> wrote:
                            [color=blue]
                            >Yup, the same guy invented fire in the early 1920's[/color]

                            Al Gore was alive and walking then?



                            -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
                            http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
                            -----== Over 80,000 Newsgroups - 16 Different Servers! =-----

                            Comment

                            • Bren

                              #29
                              Re: The dreaded question

                              >>Yup, the same guy invented fire in the early 1920's[color=blue]
                              >
                              >Al Gore was alive and walking then?[/color]

                              Oh yah. But these days he's just walking.


                              -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
                              http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
                              -----== Over 80,000 Newsgroups - 16 Different Servers! =-----

                              Comment

                              Working...