alignof Questions

8

What's the difference between sizeof and alignof? #include <iostream> #define SIZEOF_ALIGNOF(T) std::cout<< sizeof(T) << '/' << alignof(T) << std::endl int main(int...
Andrea asked 8/7, 2012 at 21:40

3

Solved

I've just stumbled upon the std::alignment_of type trait, and its soon-to-be friend std::alignment_of_v. They seem to have been specifically designed to be equivalent to a plain call to alignof, an...
Fulmination asked 2/5, 2016 at 12:2

4

Solved

For any object type T is it always the case that sizeof(T) is at least as large as alignof(T)? Intuitively it seems so, since even when you adjust the alignment of objects like: struct small { cha...
Arbogast asked 27/9, 2017 at 21:23

1

Solved

In C++, it seems that for all integer types (int, long long int, std::uint16_t, ...) and for the floating point types, it is always sizeof(T) == alignof(T). Is this compiler/platform-specific, or ...
Compliant asked 12/8, 2016 at 11:19
1

© 2022 - 2024 — McMap. All rights reserved.