Skip to content

Commit a89c8da

Browse files
committed
is_signed, is_unsigned : C++14対応として、テンプレートパラメータに算術型以外が指定された場合に対処。
1 parent 01124c1 commit a89c8da

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Diff for: reference/type_traits/is_signed.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ namespace std {
1313
##効果
1414
`is_signed`は、型`T`が符号付き算術型 (cv修飾を許容する) であるならば[`true_type`](./integral_constant-true_type-false_type.md)から派生し、そうでなければ[`false_type`](./integral_constant-true_type-false_type.md)から派生する。
1515
16+
符号付き算術型と見なす条件は以下:
1617
17-
##備考
18-
型`T`が符号付き算術型ならば、`T(-1) < T(0)` が成立する。
18+
- C++11 : [`is_arithmetic`](./is_arithmetic.md)`<T>::value && T(-1) < T(0)`
19+
- C++14 : [`is_arithmetic`](./is_arithmetic.md)`<T>::value == true`の場合、[`integral_constant`](./integral_constant-true_type-false_type.md)`<bool, T(-1) < T(0)>::value`の結果を真偽の結果とする。そうでなければ偽の結果とする。
20+
- 備考: `T`が算術型以外だった場合に、`T(0)`、`T(-1)`でテンプレートの置き換えが発生してしまうため、このような文言になっている。
1921
2022
2123
##例
@@ -58,3 +60,6 @@ int main(){}
5860
上の例でコンパイラによってはエラーになる。GCC 4.3.4, 4.5.3, Visual C++ 10.0 は `*integral_constant``operator bool()` を持っていないためエラーになる。
5961

6062

63+
##参照
64+
- [LWG Issue 2197. Specification of `is_[un]signed` unclear for non-arithmetic types](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2197)
65+

Diff for: reference/type_traits/is_unsigned.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ namespace std {
1313
##効果
1414
`is_unsigned`は、型`T`が符号なし算術型 (cv修飾を許容する) であるならば[`true_type`](./integral_constant-true_type-false_type.md)から派生し、そうでなければ[`false_type`](./integral_constant-true_type-false_type.md)から派生する。
1515
16+
符号なし算術型と見なす条件は以下:
1617
17-
##備考
18-
`T`が符号なし算術型ならば、`T(0) < T(-1)` が成立する。
18+
- C++11 : [`is_arithmetic`](./is_arithmetic.md)`<T>::value && T(0) < T(-1)`
19+
- C++14 : [`is_arithmetic`](./is_arithmetic.md)`<T>::value == true`の場合、[`integral_constant`](./integral_constant-true_type-false_type.md)`<bool, T(0) < T(-1)>::value`の結果を真偽の結果とする。そうでなければ偽の結果とする。
20+
- 備考: `T`が算術型以外だった場合に、`T(0)`、`T(-1)`でテンプレートの置き換えが発生してしまうため、このような文言になっている。
1921
2022
2123
##例
@@ -58,3 +60,6 @@ int main(){}
5860
上の例でコンパイラによってはエラーになる。GCC 4.3.4, 4.5.3, Visual C++ 10.0 は `integral_constant``operator bool()` を持っていないためエラーになる。
5961

6062

63+
##参照
64+
- [LWG Issue 2197. Specification of `is_[un]signed` unclear for non-arithmetic types](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2197)
65+

0 commit comments

Comments
 (0)