| Document #: | P3812R1 [Latest] [Status] |
| Date: | 2025-08-16 |
| Project: | Programming Language C++ |
| Audience: |
Core Working Group Evolution Working Group |
| Reply-to: |
Jarrad J. Waterloo <descender76@gmail.com> |
Allow compilers to be able to generate the default copy assignment
operator for classes that have const and &
members by making the class transparently replaceable if it
has a default copy constructor. Allow compilers to be able to generate
the default move assignment operator for classes that have
const and & members by making the class
transparently replaceable if it has a default move
constructor. See 6.7.4 Lifetime [basic.life] ¶ 9. [N5008]
|
C++26 style |
This paper (proposed) |
|
|
Adding this functionality would make the following enforcement unnecessary.
|
C.12: Don’t make data members Reason Example; bad The Note If you need a member to point to something, use
a pointer (raw or smart, and Enforcement Flag a data member that is
|
Without this functionality, besides being more code, constness has to
be enforced via even more code instead of it being enforced by use of
the const keyword or the constness associated with
references. Use of references as class members is intuitive from the
standpoint constructor based dependency injection and object proxies
which is useful for enforcing least privilege.
This features removes a current limitation of default member functions. Consequently, it is not expected to break anything as this functionality isn’t supported.