Is there a difference between {} or the default value in the initialization constructor

Is there any difference (no matter how tiny) between the three default methods of the class constructor:

Directly in the header using {}:

//foo.h
class foo{
public:
    foo(){}
}

Directly in the header using the keyword default:

//foo.h
class foo{
public:
   foo()=default;
}

In cpp using {}

//foo.h
class foo{
public:
   foo();
}

//foo.cpp
#include "foo.h"
foo::foo(){}
+4
source share
1 answer

Yes, there is a difference.

1 3 . , , , . . , memcpy . ,

:

//foo.h
class foo{
public:
   foo();
}

//foo.cpp
#include "foo.h"
foo::foo()=default;

, .

, foo(){}, [class.ctor]/6.

+6

Source: https://habr.com/ru/post/1627777/


All Articles