In 8.4.2 Explicitly-defaulted functions [dcl.fct.def.default]
of the standard,
Explicitly-defaulted functions and implicitly-declared functi
Suppose you have
// A.h
struct A {
A();
};
and
// A.cc
A::A() { }
You can change it to
// A.cc
A::A() = default;
to not force code using A.h
to be recompiled.
For a default constructor, this doesn't make much sense. = default
takes up more characters than { }
. But think of other constructor types: a copy or move constructor may become much shorter if it is no longer necessary to explicitly mention each field, and depending on the compiler and type you're dealing with, the defaulted copy/move constructor may even perform better, for example if the compiler can only detect that a memcpy
call will suffice when you use the = default
syntax.