class template
<type_traits>
std::alignment_oftemplate <class T> struct alignment_of;
Alignment of
If T is a reference type, the alignment obtained is the one required by the referenced type.
If T is an array type, the alignment obtained is the one required by the element type.
The class behaves as if defined as:
1
template<class T> struct alignment_of : integral_constant <size_t,alignof(T)> {};
1
2
3
4
5
6
7
8
9
10
11
12
// alignment_of example
#include <iostream>
#include <type_traits>
int main() {
std::cout << "alignment_of:" << std::endl;
std::cout << "char: " << std::alignment_of<char>::value << std::endl;
std::cout << "int: " << std::alignment_of<int>::value << std::endl;
std::cout << "int[20]: " << std::alignment_of<int[20]>::value << std::endl;
std::cout << "long long int: " << std::alignment_of<long long int>::value << std::endl;
return 0;
}
alignment_of char: 1 int: 4 int[20]: 4 long long int: 8
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4