lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] depr.impldec


From: Greg Chicares
Subject: Re: [lmi] depr.impldec
Date: Mon, 11 Jul 2022 19:28:50 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0

On 7/10/22 12:29, Vadim Zeitlin wrote:
[...]
>  FWIW here is my personal strategy for defining the class' special
> functions: there are several categories of classes
> 
> 1. Value-like: for them copy special functions and dtor are explicitly
>    defaulted. Move special functions are omitted, and are not available.

Already I'm struggling here, but I think the issue is nomenclature.

Is this...

class custom_string
{
  public:
    custom_string(std::string const& arg) : s_(arg) {}
    custom_string() = default;

    custom_string& operator=(std::string const& arg) {s_ = arg; return *this;}
    std::string const& value() const {return s_;}

  private:
    std::string s_;
};

a "value-like" class? If not, then what should we call classes
like this, whose data members are all such that all four
implicitly-generated copy and move operations are correct?

For this class, would you follow guideline (1) above, making
the move special functions unavailable?

I think it already does the right thing by declaring no
special member function except a default ctor. The default
implementations of the other five special operations can't
be wrong, because std::string is movable and copyable.
And the move operations may be useful.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]