summaryrefslogtreecommitdiff
path: root/absl/types/bad_any_cast.h
diff options
context:
space:
mode:
Diffstat (limited to 'absl/types/bad_any_cast.h')
-rw-r--r--absl/types/bad_any_cast.h33
1 files changed, 23 insertions, 10 deletions
diff --git a/absl/types/bad_any_cast.h b/absl/types/bad_any_cast.h
index 8ffbe4bf..3b963077 100644
--- a/absl/types/bad_any_cast.h
+++ b/absl/types/bad_any_cast.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_any_cast.h
+// -----------------------------------------------------------------------------
+//
+// This header file defines the `absl::bad_any_cast` type.
#ifndef ABSL_TYPES_BAD_ANY_CAST_H_
#define ABSL_TYPES_BAD_ANY_CAST_H_
@@ -19,21 +25,28 @@
namespace absl {
-////////////////////////
-// [any.bad_any_cast] //
-////////////////////////
-
-// Objects of type bad_any_cast are thrown by a failed any_cast.
+// -----------------------------------------------------------------------------
+// bad_any_cast
+// -----------------------------------------------------------------------------
+//
+// An `absl::bad_any_cast` type is an exception type that is thrown when
+// failing to successfully cast the return value of an `absl::any` object.
+//
+// Example:
+//
+// auto a = absl::any(65);
+// absl::any_cast<int>(a); // 65
+// try {
+// absl::any_cast<char>(a);
+// } catch(const absl::bad_any_cast& e) {
+// std::cout << "Bad any cast: " << e.what() << '\n';
+// }
class bad_any_cast : public std::bad_cast {
public:
~bad_any_cast() override;
const char* what() const noexcept override;
};
-//////////////////////////////////////////////
-// Implementation-details beyond this point //
-//////////////////////////////////////////////
-
namespace any_internal {
[[noreturn]] void ThrowBadAnyCast();