Date: Tue, 19 May 2026 14:12:19 -0500
The compiler is free to ignore attributes, but not static_assert.
On Tue, May 19, 2026, 13:40 Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
>
> [[unevaluated]] auto Func(void)
> {
> if constexpr ( some_constant0 )
> {
> return SomeType{};
> }
> else
> {
> return SomeOtherType{ 0xFF };
> }
> }
>
> The idea is that the compiler will forbid the use of Func outside of an
> unevaluated context.
>
> One trick people are using is to put this in the body:
>
> static_assert(1 == 2, "Func must only be used in an unevaluated
> context");
>
> But I think we'd be better off with an attribute that tells the compiler
> exactly what we have in mind. And of course the attribute would ensure that
> the function is not emitted in the object file.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
On Tue, May 19, 2026, 13:40 Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
>
> [[unevaluated]] auto Func(void)
> {
> if constexpr ( some_constant0 )
> {
> return SomeType{};
> }
> else
> {
> return SomeOtherType{ 0xFF };
> }
> }
>
> The idea is that the compiler will forbid the use of Func outside of an
> unevaluated context.
>
> One trick people are using is to put this in the body:
>
> static_assert(1 == 2, "Func must only be used in an unevaluated
> context");
>
> But I think we'd be better off with an attribute that tells the compiler
> exactly what we have in mind. And of course the attribute would ensure that
> the function is not emitted in the object file.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2026-05-19 19:12:35
