C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit class (2023, 2019, 2004, 2002)

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 12 Jun 2024 13:00:21 +0100
On Wed, Jun 12, 2024 at 10:50 AM Ivan Lazaric wrote:
>
> Const isn't just about not changing stuff (which can
> also be broken out of with mutable but not important),
> it gives you a different set of functionality, you get to
> overload member functions on const qualifier, return
> different types, which composes nicely with rest of
> language. How would you achieve this with a 3rd party
> tool?


I meant:

    int main(void)
    {
        int /* never changes */ a = 7;
        a = 5;
    }

But more to the point -- What I was getting at is that there are a lot
of core language features that can be achieved by using a 3rd party
code analysis tool.

I'm very surprised that 'structured binding' made it into the
language! I mean the following:

    auto& [a, b, c] = FuncReturnsTuple();

could simply be:

    auto tup = FuncReturnsTuple();
    auto &a = std::get<0u>(tup);
    auto &b = std::get<1u>(tup);
    auto &c = std::get<2u>(tup);

'Structured binding' is more of a disturbance to the core language
than the stuff I'm suggesting here.

Received on 2024-06-12 12:00:35