Modify the Result class to store the value and error separately, enabling extraction using structured binding declaration as shown in the following example:
result::Result<Image> load_image(const std::filesystem::path& path);
int main() {
const auto [image, error] = load_image(image_path);
if (error) {
// Handle the error case.
} else {
// Do something with the image.
}
}
Modify the
Resultclass to store the value and error separately, enabling extraction using structured binding declaration as shown in the following example: