C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Detection of whether a determined user-defined literal is declared

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Tue, 15 Aug 2023 20:17:02 -0400
On Tue, Aug 15, 2023 at 6:50 PM veronica alphonso via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> I'm aware about the potential pitfalls of userexpr, the main one being how to determine whether t`s value comes from a literal, but i think this could be sorted in a similar way as how std::reference_constructs/converts_from_temporary work from the compiler's perspective; if t's type isn't one of the list declared at https://eel.is/c++draft/over.literal#3, is constructed from a non-literal/temporary, and it's accessed after its lifetime begins(dynamic branches included) and before its usage in the userexpr(the concept of access being defined by https://eel.is/c++draft/intro.defs#defns.access), then the t's usage on a userexpr is ill.formed.
>
> And sure, userexpr could be used for this endeavour, but i don't want to promote it as the main solution until i fully study all of its potential details, that's why my intention was to submit an intermediate detection-feature

My issue with this is that what you're doing with `userexpr` is
reification. You're taking strings and other grammatical components
and asking the compiler to transform those elements of grammar into a
syntactic construct. This is part of reflection and should be treated
as such. We don't need a syntax specifically for doing reification of
UDLs.

Received on 2023-08-16 00:17:15