Date: Sat, 15 Jul 2023 14:14:42 +0100
On Thu, Jul 13, 2023 at 11:04 AM Matthew Taylor via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> struct Defaulted{
> //Allowed
> Defaulted& operator=(const Defaulted&) = default;
>
> //Allowed
> auto operator=(const Defaulted&) -> Defaulted& = default;
>
> //Forbidden: Proposed to allow, equivalent to returning Defaulted& explicitly.
> auto& operator=(const Defaulted&) = default;
> };
For what it's worth, I never understood why Bjarne reiterated the name
of the class inside the class. I would have just had:
class MyClass {
construct() { ......... }
destroy() { ........ }
};
and I would have had "ThisClass" be an alias for the class name, something like:
class MyClass {
construct() { ......... }
destroy() { ........ }
ThisClass &operator=(ThisClass const &rhs) { ..........; return *this; }
};
But because of Bjarne's decision: If I want to rename a class, I have
to do a "Find & Replace in Files" instead of just changing it in one
place.
If I look back over code I wrote ~20 years ago, I think I sometimes
did the following:
class MyClass {
typedef MyClass ThisClass;
};
<std-proposals_at_[hidden]> wrote:
>
> struct Defaulted{
> //Allowed
> Defaulted& operator=(const Defaulted&) = default;
>
> //Allowed
> auto operator=(const Defaulted&) -> Defaulted& = default;
>
> //Forbidden: Proposed to allow, equivalent to returning Defaulted& explicitly.
> auto& operator=(const Defaulted&) = default;
> };
For what it's worth, I never understood why Bjarne reiterated the name
of the class inside the class. I would have just had:
class MyClass {
construct() { ......... }
destroy() { ........ }
};
and I would have had "ThisClass" be an alias for the class name, something like:
class MyClass {
construct() { ......... }
destroy() { ........ }
ThisClass &operator=(ThisClass const &rhs) { ..........; return *this; }
};
But because of Bjarne's decision: If I want to rename a class, I have
to do a "Find & Replace in Files" instead of just changing it in one
place.
If I look back over code I wrote ~20 years ago, I think I sometimes
did the following:
class MyClass {
typedef MyClass ThisClass;
};
Received on 2023-07-15 13:14:53