C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [[opt_in]]

From: Jan Schultke <janschultke_at_[hidden]>
Date: Thu, 23 Jul 2026 14:38:43 +0200
> I have a few questions about this since I don't know anything about Kotlin:
>
> 1. Is the argument to the [[opt_in]] strictly required? [[opt_in]]
> unstable(); specifies intent to use unstable features well enough
> without having to spell out why it's unstable at the call site;
>

Yeah, it should be strictly required because you need to specify what
you're opting into. It could be that you're opting into a declaration
that's simultaneously using opt-in features from two libraries, like using
an experimental vector type containing experimental decimal floating-point
types. If you then just slapped [[opt_in]] on that, you wouldn't make a
conscious decision into opting into anything particular. [[opt_in]] would
just become a means of silencing a warning without really concerning
yourself with how many warnings were raised, where they came from, and for
what reason the sources raised those warnings.



> 2. Can the opt_in arg be anything? It seems that it can, based on your
> examples.
>

My examples are mostly thinking out loud. I think you would want something
like a qualified-id, similar to attributes, so you could
[[opt_in(gnu::libstdcxx_extensions)]] for libstdc++ library extensions.

And again, just because you opt into libstdc++ library extension doesn't
mean you opt into the rest of the universe, so you should be required to
provide that qualified-id.

Received on 2026-07-23 12:38:56