Article View: comp.lang.c
Article #2064Re: variadic min and max, (any some and none, cat and more)
From: Kaz Kylheku
Date: Tue, 01 Dec 2026 18:47
Date: Tue, 01 Dec 2026 18:47
71 lines
3425 bytes
3425 bytes
On 2026-12-01, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 01.12.2026 um 18:48 schrieb bartc:
>
>> I had the option to use either ° or 'deg':
>>
>> 15 deg
>
> How about that ?
>
> #include <iostream>
> #include <complex>
> #include <cmath>
>
> using namespace std;
>
> struct degree {};
>
> complex<double> operator *( double angle, degree )
complex<double> is too much of a mouthful for a complex type
you will be reaching for a lot.
How it should have been designed is that there should have
been a basic_complex<T> template and complex being a typedef
name for basic_complex<double>
You know, like string being basic_string<char>.
They don't think about ergonomics or consistency at all.
> {
> return complex<double>( sin( angle ), cos( angle ) );
> }
This sin(angle), cos(angle) argument list is the best looking
thing here --- because it's C?
If the C++ people designed it from scratch, it would be some
std::math::sin<double>(angle) type fuckery.
>
> int main()
> {
> constexpr double Pi4 = 3.1415926535897932384626433832795 / 4.0;
This is just stupid; a double only holds around 17 decimal
digits of precision (15 that are guaranteed to be preserved).
Moreover, surely C++ has a pi constant somewhere?
Evidently C++20 has ths:
#include <iostream>
#include <numbers>
// ...
std::numbers::pi;
std::numbers::pi_v<float>;
std::numbers::pi_v<long double>;
It didn't occur to them until the pandemic hit that numeric programmers might
want the language to provide pi.
They hit on the idea of avoiding pi_v<double>, like what I'm talking
about with the complex<T> verbosity above.
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
Technical Details
Message-ID:
<20261201103802.875@kylheku.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11bes8b$1gncr$1@dont-email.me> <11ek7b2$j8f6$1@raubtier-asyl.eternal-september.org> <11ekfu0$mq5n$4@dont-email.me> <11ekg71$n5p7$1@raubtier-asyl.eternal-september.org> <11ekgf8$mq5n$8@dont-email.me> <11ekjsp$pmch$2@raubtier-asyl.eternal-september.org> <11ekq4q$snda$1@dont-email.me> <11em45u$1fp0a$1@dont-email.me> <11emdhn$1ko8h$1@dont-email.me> <11emjh1$1ntap$1@dont-email.me> <11en1a0$1vqc1$1@dont-email.me> <11en399$20vkl$1@raubtier-asyl.eternal-september.org>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!.POSTED!not-for-mail From: Kaz Kylheku <046-301-5902@kylheku.com> Newsgroups: comp.lang.c Subject: Re: variadic min and max, (any some and none, cat and more) Date: Tue, 1 Dec 2026 18:47:08 -0000 (UTC) Organization: A noiseless patient Spider Lines: 71 Message-ID: <20261201103802.875@kylheku.com> References: <11bes8b$1gncr$1@dont-email.me> <11ek7b2$j8f6$1@raubtier-asyl.eternal-september.org> <11ekfu0$mq5n$4@dont-email.me> <11ekg71$n5p7$1@raubtier-asyl.eternal-september.org> <11ekgf8$mq5n$8@dont-email.me> <11ekjsp$pmch$2@raubtier-asyl.eternal-september.org> <11ekq4q$snda$1@dont-email.me> <11em45u$1fp0a$1@dont-email.me> <11emdhn$1ko8h$1@dont-email.me> <11emjh1$1ntap$1@dont-email.me> <11en1a0$1vqc1$1@dont-email.me> <11en399$20vkl$1@raubtier-asyl.eternal-september.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 01 Dec 2026 18:47:09 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2145747"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188U0PAnD+ZuZdSh4gFkA0lLd3uN0pulxg="; posting-host="f9b27e2682c192cd48131625d2ff7056" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:FZPo7nOle81CE6XyxwQ5YZ9QVpQ= sha256:JXh+ZlI2R0WIkIYLDaSOjlwFmVqppyMZddsRliRVEE0= sha1:NRWsBykfykIkLFqVG3ZUts8rsRE= sha256:MI7BZ7sYzOmuPVEIyBSYTcNnB79rjIFFZYojEod4c3g=