C++ Logo

STD-PROPOSALS

Advanced search

Subject: [std-proposals] Proposal to simplify creating constructors
From: Oleksii Tarasiuk (o.tarasiuk_at_[hidden])
Date: 2020-02-06 13:17:13


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.
  }
};

-- 
Best regards,
Oleksii Tarasiuk                          mailto:o.tarasiuk_at_[hidden]

STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups