任意のbit数の整数型を得る


何か見出しばっかりww

まぁどうでもいいか.


一つ上のままじゃ何かくやしい?ので,こんなもの作ってみた.

でもこれって安全?

#include

template
struct int_size_type {
  typedef void type;
};

template<>
struct int_size_type::digits> {
  typedef unsigned type;
};

template<>
struct int_size_type::digits> {
  typedef unsigned long type;
};

typedef int_size_type<16>::type int_16_bit_t; // 16bitのunsigned整数
typedef int_size_type<32>::type int_32_bit_t; // 32bitのunsigned整数

いろいろ欠点ありまくりですがw

とりあえず動きましたが,なんかいわゆる(あまり良くない意味で)「ハック」っぽいなぁ.


あまり良くないハックって,例えば

class My{

  struct MyImpl;
  const unsigned impl_size = /* size_of(MyImpl); */

  char pimpl_[impl_size];

public:
  My(){
    new(&pimpl_[0]) MyImpl;
  }
  ~My(){
    reinterpret_cast(&pimpl_[0]->~MyImpl());
  }
};

こんな雰囲気っていう意味.

Exceptional C++に書いてあったやつだけど.


色つけるのめんどくさk(ry


ていうか,フォントが見にくいなぁ.

行間隔とかはCSSで変えればいいけど,フォントも変えちゃっていいの?

まぁ後で気が向いたらやろう.

寝なきゃ.