Control and Query Object Alignment
C++11 allows variable alignment to be queried and controlled with alignof
and alignas
.
The alignof
operator takes a type and returns the power of 2 byte boundary on which the type instances must be allocated (as a std::size_t
). When given a reference type alignof
returns the referenced type's alignment; for arrays it returns the element type's alignment.
The alignas
specifier controls the memory alignment for a variable. The specifier takes a constant or a type; when supplied a type alignas(T)
is short hand for alignas(alignof(T))
. For example, to specify that a char array should be properly aligned to hold a float:
Read more about this topic: C++11, Core Language Functionality Improvements
Famous quotes containing the words control, query and/or object:
“We as a nation need to be reeducated about the necessary and sufficient conditions for making human beings human. We need to be reeducated not as parentsbut as workers, neighbors, and friends; and as members of the organizations, committees, boardsand, especially, the informal networks that control our social institutions and thereby determine the conditions of life for our families and their children.”
—Urie Bronfenbrenner (b. 1917)
“Such condition of suspended judgment indeed, in its more genial development and under felicitous culture, is but the expectation, the receptivity, of the faithful scholar, determined not to foreclose what is still a questionthe philosophic temper, in short, for which a survival of query will be still the salt of truth, even in the most absolutely ascertained knowledge.”
—Walter Pater (18391894)
“Consider what effects which might conceivably have practical bearings we conceive the object of our conception to have. Then our conception of these effects is the whole of our conception of the object.”
—Charles Sanders Peirce (18391914)