aligned_storage クラス

更新 : 2007 年 11 月

適切にアライメントされた型を作成します。

template<std::size_t Len, std::size_t Align>
    struct aligned_storage {
        typedef aligned-type type;
        };

パラメータ

  • Len
    オブジェクトのサイズ。

  • Align
    オブジェクトのアライメント。

解説

入れ子になった typedef (type) は、アライメント Align、サイズ Len の POD 型のシノニムです。Ty1 の型によっては、Align を alignment_of<Ty1>::value と等しくする必要があります。

使用例

 

// std_tr1__type_traits__aligned_storage.cpp 
// compile with: /EHsc 
#include <type_traits> 
#include <iostream> 
 
typedef std::tr1::aligned_storage<sizeof (int), 
    std::tr1::alignment_of<double>::value>::type New_type; 
int main() 
    { 
    std::cout << "alignment_of<int> == " 
        << std::tr1::alignment_of<int>::value << std::endl; 
    std::cout << "aligned to double == " 
        << std::tr1::alignment_of<New_type>::value << std::endl; 
 
    return (0); 
    } 
 
alignment_of<int> == 4
aligned to double == 8

必要条件

ヘッダー : <type_traits>

名前空間 : std::tr1

参照

参照

<type_traits>

alignment_of クラス