Article View: comp.lang.c
Article #2245Re: Iterators over slices and views and ranges analogs in C
From: David Brown
Date: Sat, 05 Dec 2026 12:18
Date: Sat, 05 Dec 2026 12:18
44 lines
3147 bytes
3147 bytes
On 04/12/2026 20:32, Thiago Adams wrote: > Em 04/12/2026 12:03, Ross Finlayson escreveu: >> On 12/04/2026 05:03 AM, bartc wrote: >>> On 04/12/2026 12:45, Bonita Montero wrote: >>>> Am 04.12.2026 um 13:07 schrieb bartc: >>>> >>>>> #define typename(x) (_Generic((x),\ >>>>> int: "int",\ >>>>> unsigned int: "unsigned int",\ >>>>> const int: "const int",\ >>>>> default: "other")) >>>> Compared to C++ generics this really, really sucks ! >>>> >>> >>> How would you do typename(x) in C++ then? >>> >>> That is, return the type of expression 'x' as a string (in some >>> canonical form). >>> >>> This is not really generics, but reflection. >>> >>> In my language it would be: >>> >>> 'x.typestr' >>> >>> (With 'x.type' returning a unique ordinal for the type, which can be >>> used for comparisons etc.) >>> >>> >> >> Methinks the standard says that according to _Generic construct that >> cv-qualified types are distinct types with regards generic (_Generic, >> the "generic" construct in C. >> > > To separate const from non const in _Generic use > _Generic(typeof(expr), ...) > It is for C2Y but it is already implemented in clang. > That's useful information. I knew C2y _Generic was going to accept types in _Generic's rather than just expressions, but I hadn't considered that the type does then not undergo lvalue conversion.
Technical Details
Message-ID:
<11f0ves$2okjb$5@dont-email.me>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<-kGdnSzB4bWEM4z2nZ2dnZfqn_WdnZ2d@giganews.com> <11esd12$mfam$1@raubtier-asyl.eternal-september.org> <11et39b$rj55$1@news.xmission.com> <11ett3b$1a41p$1@dont-email.me> <11euadh$1gp4t$1@dont-email.me> <11euckd$1ht9i$1@raubtier-asyl.eternal-september.org> <11eudm8$1igc3$1@dont-email.me> <a8adndvZlvSgS4_2nZ2dnZfqn_WdnZ2d@giganews.com> <11ev4gu$1uaih$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: Re: Iterators over slices and views and ranges analogs in C Date: Sat, 5 Dec 2026 13:18:36 +0100 Organization: A noiseless patient Spider Lines: 44 Message-ID: <11f0ves$2okjb$5@dont-email.me> References: <-kGdnSzB4bWEM4z2nZ2dnZfqn_WdnZ2d@giganews.com> <11esd12$mfam$1@raubtier-asyl.eternal-september.org> <11et39b$rj55$1@news.xmission.com> <11ett3b$1a41p$1@dont-email.me> <11euadh$1gp4t$1@dont-email.me> <11euckd$1ht9i$1@raubtier-asyl.eternal-september.org> <11eudm8$1igc3$1@dont-email.me> <a8adndvZlvSgS4_2nZ2dnZfqn_WdnZ2d@giganews.com> <11ev4gu$1uaih$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 05 Dec 2026 12:18:37 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2904683"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RmO35u2+LWKjdEmP1d/aZWYDIlOc/udM="; posting-host="e6744434c7b28607c9aa71bc7804445d" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:ACaoLyz/SMro2aB7d3IAcuinUUg= sha256:vtr7JCxLuJhriPI5l6HasGZb53fOHUMj6jHKNfe8wAU= sha1:EBi9vQ5vbg/cJC3x1UY45sRFDLI= sha256:Cj+jNcy/NrrqrHBNFKOauidIPjGeyfj37fnudB1UU5A= In-Reply-To: <11ev4gu$1uaih$1@dont-email.me> Content-Language: en-GB