How to explain the difference, when I compile #if 0 and #if 1 versions of the following code:
#include <cstdlib>
struct A
{
explicit A() = default; // explicitly defaulted or deleted constructors are allowed for aggregates (since C++11)
#if 1
private :
#endif
int i;
};
int
main()
{
A a = {};
return EXIT_SUCCESS;
}
- for
#if 0all is fine, compilation successful. - for
#if 1compilation failed with error message:error: chosen constructor is explicit in copy-initialization
What is the difference for expression A a = {}; depending on whether A is aggreagate or not?
Aucun commentaire:
Enregistrer un commentaire