Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

alignment_of Class

Gets alignment of type.

template<class Ty>
    struct alignment_of;


The type to query.

The type query holds the value of the the alignment of the type Ty.


// std_tr1__type_traits__alignment_of.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

Header: <type_traits>

Namespace: std

© 2015 Microsoft