GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::alignment_of(3) C++ Standard Libary std::alignment_of(3)

std::alignment_of - std::alignment_of


Defined in header <type_traits>
template< class T > (since C++11)
struct alignment_of;


Provides the member constant value equal to the alignment requirement of the type T,
as if obtained by an alignof expression. If T is an array type, returns the
alignment requirements of the element type. If T is a reference type, returns the
alignment requirements of the type referred to.


If alignof(T) is not a valid expression, the behavior is undefined.


The behavior of a program that adds specializations for alignment_of
or alignment_of_v
(since C++17) is undefined.


Helper variable template


template< class T > (since C++17)
inline constexpr std::size_t alignment_of_v = alignment_of<T>::value;

Inherited from std::integral_constant


value alignof(T)
[static] (public static member constant)


operator std::size_t converts the object to std::size_t, returns value
(public member function)
operator() returns value
(C++14) (public member function)


Type Definition
value_type std::size_t
type std::integral_constant<std::size_t, value>


template< class T >
struct alignment_of : std::integral_constant<
std::size_t,
alignof(T)
> {};


This type trait predates the alignof keyword, which can be used to obtain the same
value with less verbosity.

// Run this code


#include <cstdint>
#include <iostream>
#include <type_traits>


struct A {};
struct B {
std::int8_t p;
std::int16_t q;
};


int main()
{
std::cout << std::alignment_of<A>::value << ' ';
std::cout << std::alignment_of<B>::value << ' ';
std::cout << std::alignment_of<int>() << ' '; // alt syntax
std::cout << std::alignment_of_v<double> << '\n'; // c++17 alt syntax
}


1 2 4 8


alignof operator(C++11) queries alignment requirements of a type
alignas specifier(C++11) specifies that the storage for the variable should be
aligned by specific amount
aligned_storage defines the type suitable for use as uninitialized
(C++11)(deprecated in C++23) storage for types of given size
(class template)
aligned_union defines the type suitable for use as uninitialized
(C++11)(deprecated in C++23) storage for all given types
(class template)
max_align_t trivial type with alignment requirement as great as any
(C++11) other scalar type
(typedef)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.