C++ Logo

std-proposals

Advanced search

Re: [std-proposals] lambdas in enums

From: Zhihao Yuan <zy_at_[hidden]>
Date: Thu, 13 Mar 2025 07:17:46 +0000
On Wednesday, March 12th, 2025 at 10:04 AM, Tom Honermann via Std-Proposals <std-proposals_at_[hidden]> wrote:

> I would use deducing this to support member function call syntax.
>

> enum class E {
>

> A, B, C;
> std::string_view to_string(this E value) { … }
> };
> E e = E::A;
> auto name = e.to_string();

That looks more natural to me now.
Semicolon to end enum members,
and then refer the enum by value
in its "member" function.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

Received on 2025-03-13 07:17:53