On Thu, Feb 6, 2020 at 9:17 PM Oleksii Tarasiuk via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
Hi all!

Let's assume we have the following class:
// [Case 1]
class Person {
private:
  string name_;
  Date birthDate_;
  //.... other data members.
public:
  Person(string&& name, Date const& birthDate, SomeOtherType someOtherArg)
    : name_(forward<string>(name), birthDate_(birthDate)
  {
    // use someOtherArg to further init the instance of Person.
  }
};

I propose to add support for the following simplified form which is equivalent to [Case 1]:

// [Case 2]
class Person {
private:
  string name_;
  Date birthDate_;
  //.... other data members.
public:
  Person(auto&& .name_, auto const& .birthDate_, SomeOtherType someOtherArg)
  {
    // use someOtherArg to further init the instance of Person.
  }
};


By this model the constructor must be inline which is often not possible/recommended/desirable. 
If it is not inline, things begin to become tricky, as the declaration will still have to name the members (so the compiler knows for which definition to look for)
Members being part of the ctor declaration is ... questionable as it is no longer just an interface. 

The manual duplication is definitely annoying, but I am afraid a bunch of new corner rules and new behavior will skew the scales to "not worth the effort" just enough.




--
Best regards,
Oleksii Tarasiuk                          mailto:o.tarasiuk@gmail.com

--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals