Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Makes suitably aligned type.
template<std::size_t Len, std::size_t Align>
struct aligned_storage {
typedef aligned-type type;
};
Parameters
Len
The object size.Align
The object alignment.
Remarks
The nested typedef type is a synonym for a POD type with alignment Align and size Len. Align must be equal to alignment_of<Ty1>::value for some type Ty1.
Example
// std_tr1__type_traits__aligned_storage.cpp
// compile with: /EHsc
#include <type_traits>
#include <iostream>
typedef std::aligned_storage<sizeof (int),
std::alignment_of<double>::value>::type New_type;
int main()
{
std::cout << "alignment_of<int> == "
<< std::alignment_of<int>::value << std::endl;
std::cout << "aligned to double == "
<< std::alignment_of<New_type>::value << std::endl;
return (0);
}
alignment_of<int> == 4 aligned to double == 8
Requirements
Header: <type_traits>
Namespace: std