fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int N_FORMATS = 100;
  5.  
  6. struct pixel { float r, g, b, a; };
  7.  
  8. typedef pixel (*get_pixel_func)(void* data, int x, int y);
  9.  
  10. struct format_info_struct
  11. {
  12. uint8_t channels;
  13. get_pixel_func get_pixel;
  14. };
  15.  
  16. format_info_struct format_info_AoS[N_FORMATS];
  17.  
  18. struct
  19. {
  20. uint8_t channels[N_FORMATS];
  21. get_pixel_func get_pixel[N_FORMATS];
  22. } format_info_SoA;
  23.  
  24. int main() {
  25. cout << "Размер AoS: " << sizeof(format_info_AoS) << endl;
  26. cout << "Размер SoA: " << sizeof(format_info_SoA) << endl;
  27. return 0;
  28. }
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
Размер AoS: 1600
Размер SoA: 904