Consider the code below:
#include <array>
struct T
{
T() = delete;
};
int main()
{
std::array<T, 0> a;
a.size();
}
We default initialize a 0-sized array. Since there's no elements, no constructor of T
should be called.
However, Clang still requires T
to be default constructible, while GCC accepts the code above.
Note that if we change the array initialization to:
std::array<T, 0> a{};
Clang accepts it this time.
Does non-default-constructible T
prevent std::array<T, 0>
from being default-constructible?
Aucun commentaire:
Enregistrer un commentaire