🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #2173

Re: Iterators over slices and views and ranges analogs in C

#2173
From: bartc
Date: Fri, 04 Dec 2026 13:03
26 lines
2261 bytes
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.)

Technical Details
Message-ID: <11eudm8$1igc3$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
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>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: bartc <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Iterators over slices and views and ranges analogs in C
Date: Fri, 4 Dec 2026 13:03:03 +0000
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <11eudm8$1igc3$1@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 04 Dec 2026 13:03:05 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1655171"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1//C1KZvWAuOrUTdMjCbLop"; posting-host="b48d6065a37b4eb51257cf01ab926585"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:G1+ybe18gZTe8JKQ1AMhGlj7QBs= sha256:fVZgzxBaZ6CiL967qBGBAZOwZ04CPuptfKRX22g6Bq4=
	sha1:x6HaG85wNAITSpLJ+U2f6BJm0Qc= sha256:oKA5/W8gMBU5KjJPKGG92HsygGk+WH6WCfU1MzFJW00=
Content-Language: en-GB
In-Reply-To: <11euckd$1ht9i$1@raubtier-asyl.eternal-september.org>