A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4659/dcl.align below:

[dcl.align]

10 Declarations [dcl.dcl] 10.6 Attributes [dcl.attr] 10.6.2 Alignment specifier [dcl.align]

When the alignment-specifier is of the form alignas( constant-expression ):

The combined effect of all alignment-specifiers in a declaration shall not specify an alignment that is less strict than the alignment that would be required for the entity being declared if all alignment-specifiers appertaining to that entity were omitted. [Example:

struct alignas(8) S {};
struct alignas(1) U {
  S s;
};  

end example]

If the defining declaration of an entity has an alignment-specifier, any non-defining declaration of that entity shall either specify equivalent alignment or have no alignment-specifier. Conversely, if any declaration of an entity has an alignment-specifier, every defining declaration of that entity shall specify an equivalent alignment. No diagnostic is required if declarations of an entity have different alignment-specifiers in different translation units. [Example:

struct S { int x; } s, *p = &s;

struct alignas(16) S;           extern S* p;

end example]

[Example: An aligned buffer with an alignment requirement of A and holding N elements of type T can be declared as:

alignas(T) alignas(A) T buffer[N];

Specifying alignas(T) ensures that the final requested alignment will not be weaker than alignof(T), and therefore the program will not be ill-formed. end example]

[Example:

alignas(double) void f();                           alignas(double) unsigned char c[sizeof(double)];    extern unsigned char c[sizeof(double)];             alignas(float)
  extern unsigned char c[sizeof(double)];           

end example]


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