C++ Logo

std-proposals

Advanced search

Re: Variadic function template equivalents for operator overloading

From: Avi Kivity <avi_at_[hidden]>
Date: Wed, 5 May 2021 10:30:24 +0300
On 04/05/2021 22.29, Christopher Hallock via Std-Proposals wrote:
>
> On Tue, May 4, 2021 at 1:49 PM Phil Endecott via Std-Proposals
> <std-proposals_at_[hidden]
> <mailto:std-proposals_at_[hidden]>> wrote:
>
> Avi Kivity wrote:
> > On 04/05/2021 20.36, Phil Endecott via Std-Proposals wrote:
> >> Yes, I'm aware of that. The rationale that I've seen does not
> >> say much about a preference for variadic function syntax vs.
> >> operator-overloading. There is mention of "chevron hell" in the
> >> {fmt} library's github page. The introduction to the <format>
> >> paper P0645R10 says "printf offers some advantages, such as an
> >> arguably more natural function call API" (which I interpret as
> >> meaning arguably more natural than chained operator overloading).
> >> I'm curious as to what the committee thought - if anything -
> >> about this aspect when <format> was being considered.
> >
> > Since they adopted the proposal, it appears they agree that the
> > function-call syntax is more natural than chaining.
>
> But C++20 also added the new chained operator| for ranges, so I don't
> think it's clear what the preferred style is.
>
> (Are there any other examples?)
>
>
> That's different, though. Ranges API uses | for actual pipelining,
> e.g. f(g(h(x))) not f(a,b,c).
>

Also, there's a huge precedent in the form of shell pipes.



Received on 2021-05-05 02:30:30