From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,FROM_LOCAL_HEX, FROM_STARTS_WITH_NUMS autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 109fba,cd8ed9115942852f X-Google-NewGroupId: yes X-Google-Thread: 103376,b92b95c9b5585075 X-Google-NewGroupId: yes X-Google-Attributes: gid4f1905883f,gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de> Newsgroups: comp.lang.c++,comp.lang.ada Subject: Re: Why use C++? Date: Mon, 15 Aug 2011 14:59:38 +0200 Message-ID: References: <1e292299-2cbe-4443-86f3-b19b8af50fff@c29g2000yqd.googlegroups.com> <1fd0cc9b-859d-428e-b68a-11e34de84225@gz10g2000vbb.googlegroups.com> <9ag33sFmuaU1@mid.individual.net> <1d8wyhvpcmpkd.ggiui9vebmtl.dlg@40tude.net> <4573053c-23a1-4a23-9afb-fa4d297ff8c5@f41g2000yqh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: individual.net mAiXYxBn0ywOL5+i/q6sKQW+ka55n+hIoFo0z6r9bTfoHFL/rB Cancel-Lock: sha1:jEIfp9Ihbig2PCTuhjwpQ/OGHTs= User-Agent: Opera Mail/11.50 (Win32) Xref: g2news1.google.com comp.lang.c++:83000 comp.lang.ada:20633 Date: 2011-08-15T14:59:38+02:00 List-Id: Stuart Redmann wrote: > Stuart Redmann wrote: > [snip] >> > Be honest, how often do you really _want_ a wrapping int? > > On 12 Aug. Vinzent Hoefler wrote: >> Thinking indices instead of pointers, quite often, actually. > > Could you please provide some example? Seriously, I'm really > interested in the usage of wrapping types since in the last ten years > I have not felt the need for wrapping ints at all (well, maybe two or > three times). Indexing of a double-buffer would be the most simple example. Switching between both halves can then be expressed by a simple increment instead of conditional statements, or explicit masking of the upper bits. And while extending the data structure to a ring-buffer, masking does only work for ring-buffers with a size of power-of-two. So, using a modular type could even provide a slight performance gain in the special case while the code still works in the general case. Vinzent. -- f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.