Current c++ permits various ways of defaulted assignment operators of class.
Such as these permit implausible declarations:
A &
operator=(const A &) &&
= default;
B &
operator=(const B &) const = default;
Where A, B are c++ classes.
Proposed c++29 will forbit such declarations.
|
Code |
Current |
Proposed |
|---|---|---|
|
|
OK |
OK |
template <typename> class A { public: static const A & fn(); A & operator=(decltype(A::fn())) = default; }; |
gcc: Invalid |
OK |
|
|
OK |
Invalid |
|
|
OK |
Invalid |
|
|
OK |
Invalid |
|
|
Invalid |
Invalid |
class M { public: M & operator=(const M &) volatile; }; class A { public: volatile M m; A & operator=(const A &) = default; }; |
Deleted |
Deleted |
class A { public: A & operator=(A &); }; class B { public: A a; B & operator=(const B &) = default; }; |
Deleted |
Deleted |
class A { public: A & operator=(A &); }; class B { public: A a; B & operator=(const B &); }; B & B::operator=(const B &) = default; |
Invalid |
Invalid |
Gcc - The gnu c++ compiler:
///////////////////////////////////////////////////////////////////////////////
Mon Nov 16 01:59:24 AM UTC 2026
c++
Object-Oriented
Template
Concepts
Coroutines
Reflection
Tools B2 Build
Boost
Quickbook
Kakoune
Ugrep
Libraries
Boost
boost::asio
Asio
boost::beast
World
cppHot
+
sitemap
+ @cppHot
https://www.cpphot.tiv.cc