C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Add more methods to std::initializer_list instead of overloading

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Mon, 12 Sep 2022 14:56:11 +0300
On Mon, 12 Sept 2022 at 14:53, blacktea hamburger via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> My last email gave the reason (although the problems are different, the reason is the same).

Then we must agree to disagree whether that's a sufficient explanation for it.

> I don't understand why this guarantee is needed, is it important to generate an error if x::f is not provided? If you want x.f() to force a call to x::f, why not provide it because it selects a free function only if there is no corresponding member function?

Because it's useful to be able to guarantee that authors outside your
class hierarchy can't affect your calls, and that
in particular, ADL calls never happen. It avoids surprises in overload
resolution, and keeps the code meaning the same
over refactorings elsewhere, without having to worry that someone else
in a distant location in code that you don't even
own changes the overload resolution result.

Received on 2022-09-12 11:56:22