forked from cpreh/fcppt
/
bad_dynamic.hpp
70 lines (54 loc) · 1.34 KB
/
bad_dynamic.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright Carl Philipp Reh 2009 - 2015.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef FCPPT_CAST_BAD_DYNAMIC_HPP_INCLUDED
#define FCPPT_CAST_BAD_DYNAMIC_HPP_INCLUDED
#include <fcppt/exception.hpp>
#include <fcppt/config/external_begin.hpp>
#include <typeindex>
#include <fcppt/config/external_end.hpp>
namespace fcppt
{
namespace cast
{
/**
\brief May be thrown by \link fcppt::cast::dynamic \endlink if the cast fails
\ingroup fcpptcasts
This class provides more type information than <code>std::bad_cast</code> does.
It stores an std::type_index for the source and the destination type.
\see fcppt::cast::dynamic
*/
class bad_dynamic
:
public fcppt::exception
{
public:
/**
\brief Constructs a bad_dynamic_cast exception
\param source The source type information
\param dest The destination type information
*/
bad_dynamic(
std::type_index const &source,
std::type_index const &dest
);
/**
\brief Returns the source type information
*/
std::type_index const &
source() const;
/**
\brief Returns the destination type information
*/
std::type_index const &
destination() const;
private:
std::type_index
source_,
destination_;
};
}
}
#include <fcppt/cast/impl/bad_dynamic.hpp>
#endif