C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Declare multiple aliases at once with `using`.

From: Ferhat Geçdoğan <ferhatgectao_at_[hidden]>
Date: Fri, 22 Sep 2023 01:59:44 +0300
> Citation needed.

By saying `Most of us use aliases for declaring some complex types with
less keywords`, I mean type aliases. Like this:
`using wstring = std::basic_string<wchar_t>`. I don't think there is enough
research for that, but aren't we using aliases for long types?

> No. Especially since namespace aliases are a fundamentally different
> thing from type aliases.
Yes, you are right. But it was just an example of this purpose. It has not
only support for type aliases, but also has support for `using` directives
which adds a namespace to the scope lookup table.
With the support of multiple type alias & `using` directives, only using
one `using` keyword. It probably does cost less amount use of `using`
keyword.

> Why is removing `using` here worthwhile at all?
It just prevents duplicate use of `using` keyword. That's all.

I would prefer this:
`unsigned x, y, z;`

Not this (most cases, sometimes it's okay to emphasize some variables):
`unsigned x;
unsigned y;
unsigned z;`

Same things applies, plus `using` directives.

Maybe it's not that much worth to support that kind of thing, but it would
be great to see in C++.

Jason McKesson via Std-Proposals <std-proposals_at_[hidden]>, 21 Eyl
2023 Per, 23:39 tarihinde şunu yazdı:

> On Thu, Sep 21, 2023 at 2:31 PM Ferhat Geçdoğan via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > Most of us use aliases for declaring some complex types with less
> keywords, or something else.
>
> Citation needed.
>
> > Like this:
> >
> > `using usize = unsigned long long;
> > using int8 = std::int8_t;
> > using namespace my_namespace;` etc.
> >
> > It's doing its job. Although, it looks kinda bad, at least in my
> opinion. So, splitting them with a comma operator with one `using` would be
> a great idea. We are doing same thing in variable declarations:
> >
> > `int x { 42 }, *y;`
> >
> > With that suggested feature, we can use one `using` for multiple alias
> declarations. Like this:
> >
> > `using usize = unsigned long long,
> > int8 = std::int8_t,
> > namespace my_namespace;`.
> >
> > Isn't that useful?
>
> No. Especially since namespace aliases are a fundamentally different
> thing from type aliases.
>
> Why is removing `using` here worthwhile at all?
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-09-21 23:00:00