c++ - Does compiler instantiate default and copy constructors and copy assignment operator every time? -
the question pretty in title. consider empty class within simple program, say
struct a{ }; int main(){ }
does compiler have instantiate these functions anyway or it's implementation defined? mean, intstatiate these functions in case called (i presume, compiler may determine if called somehow).
the special member functions implicitly declared, unless odr-used, in case implicitly defined.
from n3337, §12/1 [special]
the default constructor (12.1), copy constructor , copy assignment operator (12.8), move constructor , move assignment operator (12.8), , destructor (12.4) special member functions. [ note: implementation implicitly declare these member functions class types when program not explicitly declare them. implementation implicitly define them if odr-used (3.2). see 12.1, 12.4 , 12.8. —end note ]
Comments
Post a Comment