テンプレートを使用して、整数型をバイナリ値の文字列表現に変換しています。私は以下を使用しました:
template<typename T>
std::string ToBinary(const T& value)
{
const std::bitset<std::numeric_limits<T>::digits + 1> bs(value);
const std::string s(bs.to_string());
return s;
}
int では機能しますが、 unsigned int ではコンパイルされません:
unsigned int buffer_u[10];
int buffer_i[10];
...
ToBinary(buffer_i[1]); //compile and works
ToBinary(buffer_u[1]); //doesn't compile -- ambiguous overload
理由を説明していただけますか?
編集:
はい、VS2010 を使用しています