🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #2028

Re: variadic min and max, (any some and none, cat and more)

#2028
From: Bonita Montero
Date: Mon, 30 Nov 2026 18:44
31 lines
2283 bytes
Am 30.11.2026 um 19:40 schrieb Lawrence D’Oliveiro:

> On Mon, 30 Nov 2026 17:13:21 +0100, Bonita Montero wrote:

>> C++ can do that better:
>>
>> template<typename Only>
>> constexpr Only max( const Only &only )
>> {
>> 	return only;
>> }
>>
>> template<typename First, typename Second, typename ... After>
>> constexpr common_type_t<First, Second, After ...> max( const First
>> &first, const Second &second, const After &... after )
>> {
>> 	using common = common_type_t<First, Second, After ...>;
>> 	common larger = first > second ? first : second;
>> 	if constexpr( sizeof ...( after ) != 0 )
>> 		return max( larger, after ... );
>> 	else
>> 		return larger;
>> }

> That takes a lot of code, and it still cannot cope with
> dynamically-generated lists:

It's for sure more flexible since it can handle more variations of
compatible types and it's for sure much fasger.

Technical Details
Message-ID: <11ekg71$n5p7$1@raubtier-asyl.eternal-september.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
References: <11bes8b$1gncr$1@dont-email.me> <11ek7b2$j8f6$1@raubtier-asyl.eternal-september.org> <11ekfu0$mq5n$4@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita Montero <Bonita.Montero@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: variadic min and max, (any some and none, cat and more)
Date: Mon, 30 Nov 2026 19:44:50 +0100
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <11ekg71$n5p7$1@raubtier-asyl.eternal-september.org>
References: <11bes8b$1gncr$1@dont-email.me>
 <11ek7b2$j8f6$1@raubtier-asyl.eternal-september.org>
 <11ekfu0$mq5n$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 30 Nov 2026 18:44:50 +0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org;
	logging-data="759591"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18MesRf0KsjUCz0w7PuX+Hb2H2gxqFJ+p4="; posting-host="74af7535fe23a1fc2eebd3fb26edb9d1"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:aCfyZ/6veqEWrb8nbevMTYq1yZA= sha256:86Qsr93V2zpLY07F2gIo6CTPqDItxw368cB3B3z1FQ0=
	sha1:o2P7QmOVc0KPEQV8vdZdYnmDhME= sha256:Ivfx3d+3ArhVnjoGgt8U/Dpkkf67e60kHGJEzUPJ5GE=
In-Reply-To: <11ekfu0$mq5n$4@dont-email.me>
Content-Language: de-DE