Talk:cpp/language/using declaration

I really liked this version: https://en.cppreference.com/mwiki/index.php?title=cpp/language/using_declaration&oldid=137430

And Cubbi removed nearly all of the comments and turned it back into this version, which is significantly different in clarity: https://en.cppreference.com/mwiki/index.php?title=cpp/language/using_declaration&oldid=137498

What comments do you think we can or should put back to make the important subtleties of the usage more clear? Here are mine:

In the example code, is totally useless and does absolutely nothing since the override of that  function would happen without it, and  is totally useless and does nothing because the function definition of  then hides it, but (and this is really important)  is absolutely necessary assuming the desired behavior is to keep  exposed from the parent function instead of having  from the child function hide it, thereby causing implicit casting to  if you pass a  to the child function. This is really tricky C++ behavior going on there that is begging for an explanation to even advanced users.

Comment out the three usages I mention and you'll see only one of them does anything at all. So, what do you think we can do about this? Why not put some of those clarifying comments back in?

ERCaGuy (Gabriel Staples) (talk) 20:12, 25 January 2022 (PST)


 * The intent of the example (mostly borrowed from namespace.udecl/11) was to demonstrate the directly preceding sentence in the text ("hides or overrides"). As such, to be relevant, it needs to be three lines: one that hides, one that overrides, and one that adds to the as-if set of direct members of the derived class, with minimal wiring to make it compile. This is not the place for a tutorial on the use of the language feature or on virtual functions. --Cubbi (talk) 20:35, 25 January 2022 (PST)

In the section titled "Inheriting constructors",

struct B1 { B1(int); }; struct D1 : B1 { using B1::B1; // The set of candidate inherited constructors is  // 1. B1(const B1&) // 2. B1(B1&&) // 3. B1(int) // D1 has the following constructors: // 1. D1

D1 is not generated, because the base class B1 has no default constructor.


 * the page says "D1 = delete" which correctly describes D1's implicitly defined default constructor. --Cubbi (talk) 20:48, 25 January 2022 (PST)