fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. int main()
  5. {
  6. using storage_type =
  7. std::aligned_storage<sizeof(double), alignof(double)>::type;
  8. using union_storage_type =
  9. std::aligned_union<sizeof(double), double>::type;
  10.  
  11. storage_type storage;
  12. union_storage_type union_storage;
  13.  
  14. std::cout << sizeof(storage_type) << '\n';
  15. std::cout << sizeof(union_storage_type) << '\n';
  16. std::cout << sizeof(storage) << '\n';
  17. std::cout << sizeof(union_storage) << '\n';
  18. std::cout << sizeof(double) << '\n';
  19. return 0;
  20. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
8
8
8
8
8