std::array< T, 0 >
があれば、それはなぜ空ではないですか?なぜstd :: array < T, 0 >が空でないのですか?
std::array<int,0>
のために、空のベースの最適化(EBO)が適用されていないことを
false
と
#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;
}
利回り
4
4
8
意味し、帰国
std::is_empty< std::array< int, 0 > >::value
:私はのような "空" を意味します。
このstd::tuple<>
(注:テンプレートパラメータ)ことを考えると私には特に奇妙に思えるすなわち、std::is_empty<std::tuple<>>::value
はtrue
を得ない、空です。
質問:0
のサイズがstd::array
の特殊ケースの場合、それはなぜですか?スタンダードの意図的な見落としや見落としですか?
仕事GCC 4.8は== '1'はsizeof(STD ::配列)以来、違っそれを行う(またはのlibstdC++、それに来て)いるようです。しかし、あなたは "one * possible * implementation"と言っていると思います。私は推論を受け入れます。ありがとう! –
GCCは 'value_type _M_instance [_Nm? 'sizeof(int)' –
私はLiveWorkSpace.orgの 'sizeof(std :: array)== 1'をGCC 4.8で見ています。奇妙な。 –