# std::alignment_of

< cpp‎ | types

C++
 Compiler support Freestanding and hosted Language Standard library headers Named requirements Feature test macros (C++20) Language support library Concepts library (C++20) Diagnostics library General utilities library Strings library Containers library Iterators library Ranges library (C++20) Algorithms library Numerics library Localizations library Input/output library Filesystem library (C++17) Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11) Technical specifications Symbols index External libraries

Utilities library
 Language support Type support (basic types, RTTI, type traits) Library feature-test macros (C++20) Dynamic memory management Program utilities Error handling Coroutine support (C++20) Variadic functions launder(C++17) initializer_list(C++11) source_location(C++20) Three-way comparison (C++20) three_way_comparablethree_way_comparable_with(C++20)(C++20) strong_ordering(C++20) weak_ordering(C++20) partial_ordering(C++20) common_comparison_category(C++20) compare_three_way_result(C++20) compare_three_way(C++20) strong_order(C++20) weak_order(C++20) partial_order(C++20) compare_weak_order_fallback(C++20) is_eqis_neqis_ltis_lteqis_gtis_gteq(C++20)(C++20)(C++20)(C++20)(C++20)(C++20)
General utilities
 Formatting library (C++20) hash(C++11) integer_sequence(C++14)
Relational operators (deprecated in C++20)
Integer comparison functions
 cmp_equalcmp_lesscmp_less_than(C++20)(C++20)(C++20)
 cmp_not_equalcmp_greatercmp_greater_than(C++20)(C++20)(C++20)
(C++20)
Swap and type operations
 swap ranges::swap(C++20) exchange(C++14) declval(C++11)
 forward(C++11) move(C++11) move_if_noexcept(C++11) as_const(C++17) to_underlying(C++23)
Common vocabulary types
 pair tuple(C++11) optional(C++17) any(C++17) variant(C++17)
 tuple_size(C++11) tuple_element(C++11) apply(C++17) make_from_tuple(C++17)
Elementary string conversions
 to_chars(C++17) from_chars(C++17)
 chars_format(C++17)
Stacktrace

Type support
Basic types
Fundamental types
Fixed width integer types (C++11)
 ptrdiff_t size_t max_align_t(C++11) byte(C++17)
 nullptr_t(C++11) offsetof NULL
Numeric limits
C numeric limits interface
Runtime type information
 type_info type_index(C++11)
Type traits
Type categories
 is_void(C++11) is_null_pointer(C++14) is_array(C++11) is_pointer(C++11) is_enum(C++11) is_union(C++11) is_class(C++11) is_function(C++11)
 is_object(C++11) is_scalar(C++11) is_compound(C++11) is_integral(C++11) is_floating_point(C++11) is_fundamental(C++11) is_arithmetic(C++11)
Type properties
 is_const(C++11) is_volatile(C++11) is_empty(C++11) is_polymorphic(C++11) is_final(C++14) is_abstract(C++11) is_aggregate(C++17) is_trivial(C++11)
 is_trivially_copyable(C++11) is_standard_layout(C++11) is_literal_type(C++11)(until C++20) is_pod(C++11)(deprecated in C++20) is_signed(C++11) is_unsigned(C++11) is_bounded_array(C++20) is_unbounded_array(C++20) is_scoped_enum(C++23)
Type trait constants
Metafunctions
(C++17)
Constant evaluation context
Supported operations
 is_constructibleis_trivially_constructibleis_nothrow_constructible(C++11)(C++11)(C++11) is_copy_constructibleis_trivially_copy_constructibleis_nothrow_copy_constructible(C++11)(C++11)(C++11) is_move_constructibleis_trivially_move_constructibleis_nothrow_move_constructible(C++11)(C++11)(C++11) is_assignableis_trivially_assignableis_nothrow_assignable(C++11)(C++11)(C++11)
 is_copy_assignableis_trivially_copy_assignableis_nothrow_copy_assignable(C++11)(C++11)(C++11) is_move_assignableis_trivially_move_assignableis_nothrow_move_assignable(C++11)(C++11)(C++11) is_destructibleis_trivially_destructibleis_nothrow_destructible(C++11)(C++11)(C++11) has_virtual_destructor(C++11) is_swappable_withis_swappableis_nothrow_swappable_withis_nothrow_swappable(C++17)(C++17)(C++17)(C++17)
Relationships and property queries
 is_same(C++11) is_base_of(C++11) is_convertibleis_nothrow_convertible(C++11)(C++20) is_layout_compatible(C++20) is_corresponding_member(C++20)
 alignment_of(C++11) rank(C++11) extent(C++11) is_invocableis_invocable_ris_nothrow_invocableis_nothrow_invocable_r(C++17)(C++17)(C++17)(C++17)
Type modifications
Type transformations
 aligned_storage(C++11) aligned_union(C++11) decay(C++11) remove_cvref(C++20) enable_if(C++11) void_t(C++17)
 conditional(C++11) common_type(C++11) common_reference(C++20) underlying_type(C++11) result_ofinvoke_result(C++11)(until C++20)(C++17) type_identity(C++20)

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

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.

## Contents

###  Helper variable template

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

## Inherited from std::integral_constant

### Member constants

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

### Member functions

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

### Member types

 Type Definition value_type std::size_t type std::integral_constant

### Possible implementation

 template< class T > struct alignment_of : std::integral_constant< std::size_t, alignof(T) > {};
{"ft_lang_label":"__label__en","ft_lang_prob":0.61176014,"math_prob":0.9829937,"size":2337,"snap":"2021-31-2021-39","text_gpt3_token_len":583,"char_repetition_ratio":0.1508787,"word_repetition_ratio":0.09411765,"special_character_ratio":0.27513906,"punctuation_ratio":0.17619048,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9889202,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-28T01:26:55Z\",\"WARC-Record-ID\":\"<urn:uuid:d2c4afe9-bf91-48f7-b0ed-2acbf4722664>\",\"Content-Length\":\"100258\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:54c28ba1-26f1-4e05-ae43-e0fff8a89619>\",\"WARC-Concurrent-To\":\"<urn:uuid:5ca011fe-c435-4364-9feb-1c85952d10e9>\",\"WARC-IP-Address\":\"74.114.90.46\",\"WARC-Target-URI\":\"https://en.cppreference.com/w/cpp/types/alignment_of\",\"WARC-Payload-Digest\":\"sha1:PGJGHWAWKD6BQGTETIACTBUTB4J4KH55\",\"WARC-Block-Digest\":\"sha1:NZ33SRZSLDF6HSUTBWM4ZQPUOAHS7PS6\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780058589.72_warc_CC-MAIN-20210928002254-20210928032254-00572.warc.gz\"}"}