std::make_unsigned - cppreference.com
提供: cppreference.com
<tbody> </tbody>
|
|
(C++11以上) | |
T が整数 (bool を除く) または列挙型であれば、同じ cv 修飾を持つ T に対応する符号なし整数型であるメンバ型 type が提供されます。 列挙型に対応する符号なし整数型は、その列挙型と sizeof が同じ最も小さなランクを持つ符号なし整数型です。
|
そうでなければ、動作は未定義です。 |
(C++20未満) |
|
そうでなければ、プログラムは ill-formed です。 |
(C++20以上) |
メンバ型
| 名前 | 定義 |
type
|
T に対応する符号なし整数型
|
ヘルパー型
<tbody> </tbody>
|
|
(C++14以上) | |
例
#include <iostream> #include <type_traits> int main() { typedef std::make_unsigned<char>::type char_type; typedef std::make_unsigned<int>::type int_type; typedef std::make_unsigned<volatile long>::type long_type; bool ok1 = std::is_same<char_type, unsigned char>::value; bool ok2 = std::is_same<int_type, unsigned int>::value; bool ok3 = std::is_same<long_type, volatile unsigned long>::value; std::cout << std::boolalpha << "char_type is 'unsigned char'? : " << ok1 << '\n' << "int_type is 'unsigned int'? : " << ok2 << '\n' << "long_type is 'volatile unsigned long'? : " << ok3 << '\n'; }
出力:
char_type is 'unsigned char'? : true int_type is 'unsigned int'? : true long_type is 'volatile unsigned long'? : true