In this article, I cover Default constructuctible lambdas.
C++20 Lambda Extensions: Lambda Default Constructors
by Gajendra Gulgulia
From the article:
1. Default construction: Very short background
In C++ objects are default constructible if they satisfy certain conditions. The set of conditions vary and I’ll not go into all the details of what they are as it will be out of the scope of this article. Consider the Person class with default constructor in line 3.
class Person{ public: Person() = default; //default constructor Person(std::uint32_t age, std::string name): age_{age}, name_{name} { /*empty body */ } std::string getName() const { return name_;} std::uint32_t getAge() const { return age_; } void setAge(const std::uint32_t age) {age_ = age;} void setName(const std::string& name){name_ = name;} private: std::uint32_t age_{}; std::string name_{}; };
Add a Comment
Comments are closed.