expected -- expected: 基本的な例示コードを追加(#1066)

1 · cpprefjp · Jan. 25, 2023, 3:33 p.m.
diff --git a/reference/expected/expected.md b/reference/expected/expected.md index 34e775ca7..b10bda892 100644 --- a/reference/expected/expected.md +++ b/reference/expected/expected.md @@ -84,19 +84,45 @@ namespace std { ## 例 ```cpp example #include <expected> +#include <iomanip> #include <iostream> +#include <string> + +// 整数除算 +std::expected<int, std::string> idiv(int a, int b) +{ + if (b == 0) { + return std::unexpected{"divide by zero"}; + } + if (a % b != 0) { + return std::une...