C++ Logo


Advanced search

Subject: Re: [std-proposals] Using `= default; ` Constructors to Remove Boilerplate Constructors
From: Viktor Kireev (vitech-job_at_[hidden])
Date: 2020-02-06 03:53:35

On Thursday, 6 February 2020 08:00:06 MSK Alex Brachet-Mialot via Std-
Proposals wrote:
> Hi all,
> I just wanted to float this idea that I have had for a while.
> I find many constructors often follow this format Type(a_t a, b_t b) :
> a(a), b(b) {}. This can get tedious quickly and look very ugly. Such
> types can sometimes be aggregates which solves this problem, but not
> always, aggregates have prerequisites that very few types can
> realistically follow.
> I was thinking that `= default` could be used in this circumstance.

What types should this work for?

class C {
    std::unique_ptr<int> a;

    C(std::unique_ptr<int> a) = default;

What should the compiler do?

Victor Kireev

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

Standard Proposals Archives on Google Groups