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.

4
  • This destructor reference might be a good start. Commented Mar 7, 2016 at 13:55
  • 1
    1. Yes. 2. See the chart in this answer: stackoverflow.com/a/15181645/576911 Commented Mar 7, 2016 at 14:01
  • @HowardHinnant Thanks for the link. So = default does count as user-defined and prohibits the compiler from generating special members. Commented Mar 7, 2016 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. Commented Mar 7, 2016 at 14:13

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.