summaryrefslogtreecommitdiff
path: root/absl/types/bad_optional_access.h
diff options
context:
space:
mode:
Diffstat (limited to 'absl/types/bad_optional_access.h')
-rw-r--r--absl/types/bad_optional_access.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/absl/types/bad_optional_access.h b/absl/types/bad_optional_access.h
index c4c74447..e9aa8b83 100644
--- a/absl/types/bad_optional_access.h
+++ b/absl/types/bad_optional_access.h
@@ -1,4 +1,4 @@
-// Copyright 2017 The Abseil Authors.
+// Copyright 2018 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -11,6 +11,12 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// bad_optional_access.h
+// -----------------------------------------------------------------------------
+//
+// This header file defines the `absl::bad_optional_access` type.
#ifndef ABSL_TYPES_BAD_OPTIONAL_ACCESS_H_
#define ABSL_TYPES_BAD_OPTIONAL_ACCESS_H_
@@ -19,6 +25,23 @@
namespace absl {
+// -----------------------------------------------------------------------------
+// bad_optional_access
+// -----------------------------------------------------------------------------
+//
+// An `absl::bad_optional_access` type is an exception type that is thrown when
+// attempting to access an `absl::optional` object that does not contain a
+// value.
+//
+// Example:
+//
+// absl::optional<int> o;
+//
+// try {
+// int n = o.value();
+// } catch(const absl::bad_optional_access& e) {
+// std::cout << "Bad optional access: " << e.what() << '\n';
+// }
class bad_optional_access : public std::exception {
public:
bad_optional_access() = default;