本文测试c++中tuple的大小。
#include <iostream>
#include <string>
#include <tuple>
using namespace std;
int main()
{
cout << "size = " << sizeof(tuple<char>) << endl;
cout << "size = " << sizeof(tuple<int>) << endl;
cout << "size = " << sizeof(tuple<float>) << endl;
cout << "size = " << sizeof(tuple<char, int>) << endl;
cout << "size = " << sizeof(tuple<int, float>) << endl;
cout << "size = " << sizeof(tuple<char, float>) << endl;
cout << "size = " << sizeof(tuple<int,float,int>) << endl;
}
运行结果
size = 1
size = 4
size = 4
size = 8
size = 8
size = 8
size = 12