module pind.samples.ja.arithmetic.arithmetic_15; import core.checkedint; void main() { // テストのためにオーバーフローを発生させてみよう int a = int.max - 1; int b = 2; // 'adds'関数内の加算演算がオーバーフローすると、 // この変数は'true'になる: bool hasOverflowed = false; int result = adds(a, b, hasOverflowed); if (hasOverflowed) { // オーバーフローした'result'は使用してはならない。 // ... } else { // 'result'は使用できる。 // ... } }