Re: [GD-General] Offset a void pointer
Brought to you by:
vexxed72
From: Richard F. <ra...@gm...> - 2004-10-13 09:24:46
|
i assume its not faster, but i personally think its better C++ (activley using these kinds of thing keeps your mind where it needs to be to think out better solutions to more complex problems) for example, I use ampersand suffixed return values for my container classes that implement operator[]. that way you can assign stuff to indexes. so really it just boils down to what you're comfortable with, with te caveat that maybe you should be comfortable with using cast to lvalue. On Tue, 12 Oct 2004 10:04:35 -0700, Dan Thompson <da...@ar...> wrote: > Is there any problem with: > > BufferPtr = (char*)BufferPtr + stride; > > ? Compiles for me... certainly easier to read than (char*&)BufferPtr. Is > one subtly faster than the in a way I'm not aware? > > -Dan > > > > > Richard Fabian wrote: > > >just add an ampersand to your cast to make it a reference pointer not > >just a pointer > > > >void *BufferPtr; > >unnsigned int stride=5; > >// should now compile > >(char*&)BufferPtr+=stride; > > > > > >On Tue, 12 Oct 2004 14:17:14 +0200, CAVEY GERARD <ger...@sg...> wrote: > > > > > >>Hi > >> > >>I have little question > >>It seems impossible to me to offset a void pointer with the += operator > >>can someone explain me why ? > >>I don t really understand the compiler here ... the left casting should > >>give him the memory unit size , right?Is left casting forbidden? > >> > >>void *BufferPtr; > >>unnsigned int stridde=5; > >>//doesnt compile ! > >>(char*)BufferPtr+=stride; > >>//will compile > >>BufferPtr=(char*)BufferPtr+stride; > >> > >>Thanks > >>GC. > >> > >>************************************************************************* > >>Ce message et toutes les pieces jointes (ci-apres le "message") sont > >>confidentiels et etablis a l'intention exclusive de ses destinataires. > >>Toute utilisation ou diffusion non autorisee est interdite. > >>Tout message electronique est susceptible d'alteration. > >>SG Asset Management et ses filiales declinent toute responsabilite au titre > >>de ce message s'il a ete altere, deforme ou falsifie. > >> > >>Decouvrez l'offre et les services de SG Asset Management sur le site > >>www.sgam.fr > >> > >> ******** > >> > >>This message and any attachments (the "message") are confidential and > >>intended solely for the addressees. > >>Any unauthorised use or dissemination is prohibited. > >>E-mails are susceptible to alteration. > >>Neither SG Asset Management nor any of its subsidiaries or affiliates shall > >>be liable for the message if altered, changed or falsified. > >> > >>************************************************************************* > >> > >>------------------------------------------------------- > >>This SF.net email is sponsored by: IT Product Guide on ITManagersJournal > >>Use IT products in your business? Tell us what you think of them. Give us > >>Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more > >>http://productguide.itmanagersjournal.com/guidepromo.tmpl > >>_______________________________________________ > >>Gamedevlists-general mailing list > >>Gam...@li... > >>https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > >>Archives: > >>http://sourceforge.net/mailarchive/forum.php?forum_id=557 > >> > >> > >> > > > > > >------------------------------------------------------- > >This SF.net email is sponsored by: IT Product Guide on ITManagersJournal > >Use IT products in your business? Tell us what you think of them. Give us > >Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more > >http://productguide.itmanagersjournal.com/guidepromo.tmpl > >_______________________________________________ > >Gamedevlists-general mailing list > >Gam...@li... > >https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > >Archives: > >http://sourceforge.net/mailarchive/forum.php?forum_id=557 > > > > > > > > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IT Product Guide on ITManagersJournal > Use IT products in your business? Tell us what you think of them. Give us > Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more > http://productguide.itmanagersjournal.com/guidepromo.tmpl > _______________________________________________ > Gamedevlists-general mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=557 > |