Here is my code:
#include <array>
struct A
{
A(int) {}
};
std::array<A, 42> a;
int main()
{
return 0;
}
And the error:
$ g++ -Wall -Wextra -Wpedantic main.cpp
main.cpp:9:19: error: use of deleted function `std::array<A, 42ul>::array()'
std::array<A, 42> a;
^
In file included from main.cpp:1:0:
/usr/include/c++/6/array:90:12: note: `std::array<A, 42ul>::array()' is implicitly deleted because the default definition would be ill-formed:
struct array
^~~~~
/usr/include/c++/6/array:90:12: error: no matching function for call to `A::A()'
main.cpp:5:5: note: candidate: A::A(int)
A(int) {}
^
main.cpp:5:5: note: candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr A::A(const A&)
struct A
^
main.cpp:3:8: note: candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr A::A(A&&)
main.cpp:3:8: note: candidate expects 1 argument, 0 provided
My environment:
$ g++ --version
g++ (Debian 6.3.0-6) 6.3.0 20170205
Related:
Why I expected this to work:
std::array
does not initialize its elements upon creation. The size of A
is well defined.