Udostępnij za pośrednictwem


aligned_storage — Klasa

Tworzy odpowiednio wyrównany typ.

Składnia

template <std::size_t Len, std::size_t Align>
struct aligned_storage;

template <std::size_t Len, std::size_t Align = alignment_of<max_align_t>::value>
using aligned_storage_t = typename aligned_storage<Len, Align>::type;

Parametry

Len
Rozmiar obiektu.

Wyrównaj
Wyrównanie obiektu.

Uwagi

Typedef type elementu członkowskiego szablonu jest synonimem typu zasobnika z wyrównaniem Wyrównanie i rozmiar Len. Wyrównanie musi być równe alignment_of<T>::value dla określonego typu Tlub do wyrównania domyślnego.

Przykład

#include <type_traits>
#include <iostream>

typedef std::aligned_storage<sizeof (int),
    std::alignment_of<double>::value>::type New_type;
int main()
    {
    std::cout << "alignment_of<int> == "
        << std::alignment_of<int>::value << std::endl;
    std::cout << "aligned to double == "
        << std::alignment_of<New_type>::value << std::endl;

    return (0);
    }
alignment_of<int> == 4
aligned to double == 8

Wymagania

Nagłówek:<type_traits>

Przestrzeń nazw: std

Zobacz też

<type_traits>
alignment_of, klasa