Re: size_t best practice

Liste des GroupesRevenir à cl c 
Sujet : Re: size_t best practice
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.c
Date : 18. Aug 2024, 14:40:13
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240818154013.00002ed7@yahoo.com>
References : 1 2
User-Agent : Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
On 18 Aug 2024 12:17:36 GMT
ram@zedat.fu-berlin.de (Stefan Ram) wrote:

Mark Summerfield <mark@qtrac.eu> wrote or quoted:
So is it considered best practice to use int, long, long long, or
size_t, in situations like these? 
 
  In *cough*C++*cough* you could whip up a "SafeSize" class with
  a bulletproof "operator--", so you don't space on the check.
  You could still keep cranking out your code in what's basically C
and just cherry-pick this one gnarly feature from that other language.
 
SafeSize& operator--()
{ if( value == 0 )
  { throw std::underflow_error("SafeSize decrement underflow"); }
  --value;
  return *this; }

But that's not a desired behavior for people that want to write
downcounting for() loops in intuitive manner.



Date Sujet#  Auteur
18 Aug 24 * size_t best practice23Mark Summerfield
18 Aug 24 +* Re: size_t best practice3Ike Naar
18 Aug 24 i`* Re: size_t best practice2Mark Summerfield
20 Aug 24 i `- Re: size_t best practice1Andrey Tarasevich
18 Aug 24 +- Re: size_t best practice1Michael S
18 Aug 24 +- Re: size_t best practice1Tim Rentsch
18 Aug 24 +* Re: size_t best practice6Stefan Ram
18 Aug 24 i+* Re: size_t best practice4Michael S
19 Aug 24 ii`* Re: size_t best practice3Tim Rentsch
19 Aug 24 ii `* Re: size_t best practice2Michael S
19 Aug 24 ii  `- Re: size_t best practice1Tim Rentsch
18 Aug 24 i`- Re: size_t best practice1Tim Rentsch
20 Aug 24 +* Re: size_t best practice7Andrey Tarasevich
20 Aug 24 i+* Re: size_t best practice3Andrey Tarasevich
20 Aug 24 ii`* Re: size_t best practice2Andrey Tarasevich
22 Aug 24 ii `- Re: size_t best practice1Tim Rentsch
22 Aug 24 i`* Re: size_t best practice3Tim Rentsch
22 Aug 24 i `* Re: size_t best practice2Ike Naar
22 Aug 24 i  `- Re: size_t best practice1Tim Rentsch
24 Aug 24 +* Re: size_t best practice3Bonita Montero
25 Aug 24 i`* Re: size_t best practice2Bonita Montero
26 Aug 24 i `- Re: size_t best practice1Vir Campestris
27 Aug 24 `- Re: size_t best practice1Bonita Montero

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal