isocpp / CppCoreGuidelines

The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
Other
42.93k stars 5.44k forks source link

reference member #1809

Open BjarneStroustrup opened 3 years ago

BjarneStroustrup commented 3 years ago

I think we need a rule banning reference members. All we have is a note: (Note that using a reference member is almost always wrong.)

shaneasd commented 3 years ago

Related/Duplicate: #1707

hsutter commented 3 years ago

We have this in C.12 so perhaps a PR to propose updates to that?

Ivarun commented 2 weeks ago

I’m curious why this is desirable? Aren’t reference members (passed as constructor parameters) a perfectly valid way to do dependency injection in C++?