Given any std::array< T, 0 >
, why is it not empty? I mean "empty" as in:
std::is_empty< std::array< int, 0 > >::value
returning false
and
#include <iostream>
#include <tuple>
#include <array>
struct Empty {};
int main()
{
std::cout << sizeof(std::tuple<int>) << std::endl;
std::cout << sizeof(std::tuple<int,Empty>) << std::endl;
std::cout << sizeof(std::tuple<int,std::array<int,0>>) << std::endl;
}
yields
4
4
8
which means, that for std::array<int,0>
, the empty base optimization (EBO) is not applied.
This seem especially strange to me given that std::tuple<>
(note: no template parameters) is empty, i.e., std::is_empty<std::tuple<>>::value
does yield true
.
Question: Why is that, given that size 0
is already a special case for std::array
? Is it intentional or an oversight in the standard?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…