0

Let's see this code:

struct S {
  virtual ~S() = default;
};

First question is: is this OK according to the standard? I cannot find the relevant syntax on cppreference. Second question is will this prohibit the compiler from generating copy/move constructor/assignment operator? Reference to the standard would be appreciated.

Lingxi
  • 14,579
  • 2
  • 37
  • 93
  • [This destructor reference](http://en.cppreference.com/w/cpp/language/destructor) might be a good start. – Some programmer dude Mar 07 '16 at 13:55
  • 1
    1. Yes. 2. See the chart in this answer: http://stackoverflow.com/a/15181645/576911 – Howard Hinnant Mar 07 '16 at 14:01
  • @HowardHinnant Thanks for the link. So `= default` does count as user-defined and prohibits the compiler from generating special members. – Lingxi Mar 07 '16 at 14:05
  • 1
    @Lingxi: Yes, but said a little more precisely, it counts as user-*declared* and prohibits the compiler from generating the move members. The copy members are still generated with a user-declared destructor, but that behavior is deprecated. To avoid depending on deprecated behavior, declare the copy members if you declare the destructor. – Howard Hinnant Mar 07 '16 at 14:13

0 Answers0