Inflection
Morphology Inflection
Loading...
Searching...
No Matches
ClassCastException.hpp
1/*
2 * Copyright 2016-2024 Apple Inc. All rights reserved.
3 */
4#pragma once
5
6#include <inflection/exception/fwd.hpp>
7#include <inflection/exception/RuntimeException.hpp>
8
13class INFLECTION_CLASS_API inflection::exception::ClassCastException
15{
16public:
20
21public:
26 template<typename T, typename U>
27 static T verifyCast(U* u)
28 {
29 if (!u) return static_cast<T>(nullptr);
30 auto t = dynamic_cast<T>(u);
31 if (!t) throw ClassCastException();
32 return t;
33 }
34
35public:
43 explicit ClassCastException(const std::u16string& message);
48};
Used to indicate an error casting from one class to other.
ClassCastException(const std::u16string &message)
Used to indicate a generic exception occurring at runtime.
The C++ namespace for Inflection.
Definition fwd.hpp:11