C++ Logo

std-discussion

Advanced search

Re: What is the reason of one rule of C++ ?

From: Vadim Flyagin <vadim.flyagin_at_[hidden]>
Date: Sun, 12 Nov 2023 08:45:22 +0200
Before getting to know about the existence of this mailing list, I asked
the same question to Bjarne Stroustrup in a private e-mail. He replied that
he is interested in this question too: “I thought it had to be a bug but
MS, Clang, and GCC all do the same, so it's likely to be in the standard.
Now I'm curious. It still looks like a bug to me. Thanks.”
вс, 12 нояб. 2023 г. в 06:04, Vadim Flyagin <vadim.flyagin_at_[hidden]>:

> Dear experts in the ISO C++ Standard!
>
> Konstantin Vladimirov, who is an informatics lecturer at Moscow Institute
> of Physics and Technology (in particular, he teaches C++), initiated a
> discussion recently about the following issue in his Telegram channel [1].
>
> He asked the following question and said that he does not know the answer,
> nor have his subscribers found the answer yet. Maybe you could answer this
> question? Below is my translation of this question from the Russian:
>
> “Some strange kind of C++.
>
> Respected reader of my channel @MSerhiy has noticed a funny thing: there
> are different rules of overloading for structures and for primitive types
> in this example: [2].
>
> Quite soon, I grubbed up the answer in the standard.
>
> C++20, [expr.type] "If a prvalue initially has the type “cv T”, where T is
> a cv-unqualified non-class, non-array type, the type of the expression is
> adjusted to T prior to any further analysis"
>
> But I started pondering during the process for some reason. Just
> hypothetically: why was this done so? This helps what things and when? I
> have no ideas.
>
> I propose to speculate concerning the source for this rule in this thread.”
>
> Best wishes, Vadim.
>
> [1] https://t.me/cpp_lects_rus/136
>
> [2] https://godbolt.org/z/YT9bo7ore
>
>

Received on 2023-11-12 06:45:37