C++ Logo

sg10

Advanced search

Re: [SG10] [isocpp-core] Feature-test macro for ADL calls with template arguments?

From: Richard Smith <richardsmith_at_[hidden]>
Date: Mon, 8 Jun 2020 17:38:45 -0700
On Mon, Jun 8, 2020 at 5:23 PM Ville Voutilainen <
ville.voutilainen_at_[hidden]> wrote:

> On Tue, 9 Jun 2020 at 03:01, Richard Smith <richardsmith_at_[hidden]>
> wrote:
>
> >> We have a language fix that makes hidden friend templates work with
> >> ADL when template arguments are provided
> >> for a call. We have work-arounds that don't come even close to
> >> achieving the same functionality.
> >
> >
> > The way I see it is that we have an idiom (or "workaround" if you
> prefer) that works reliably and provides a superset of the functionality of
> P0846. (The language-level approach, by contrast, works in strictly fewer
> cases, and lacks the functionality of letting you choose to provide a
> custom fallback.) What functionality is missing from the 'using + ADL call'
> idiom that P0846 provides?
>
> Simplicity. I need to write that using-declaration near every call
> site where I want to invoke get<>. That's not
> a functionality-superset, it's a completely different thing, a
> completely different API flavor. And for users
> who by and large prefer not to be bothered with namespaces everywhere,
> it's a completely inferior
> API flavor, and an incredibly noisy one at that.
>

OK. I would consider that syntax rather than functionality, but I would
admit the line between the two can be blurry.


> >> It would seem
> >> rather reasonable to allow programmers to detect when they can use the
> >> new superior functionality.
> > The SG10 policy has historically been to not include a feature test
> macro where there is a simple syntactic alternative that gets you the same
> functionality regardless of compiler support. As far as I'm aware, there
> is, in this case.
>
> I am yet to see a simple syntactic alternative in this thread. But
> well, if this is not a reasonable feature-macro
> addition for SG10, then we'll live without it. To me, it seems exactly
> the kind of feature-detection use case a feature-testing
> macro is good for.
>

Can you give an example of how you'd imagine people using this? If we're
expecting them to write

#ifdef __cpp_something
  get<1>(qp);
#else
  something_else(qp);
#endif

instead of, say,

  using adl::get;
  get<1>(qp);

then it seems to me that the feature test macro doesn't give us syntactic
simplicity either.

Received on 2020-06-08 19:42:06