]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/type_index/include/boost/type_index/runtime_cast/detail/runtime_cast_impl.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / type_index / include / boost / type_index / runtime_cast / detail / runtime_cast_impl.hpp
CommitLineData
7c673cae
FG
1//
2// Copyright (c) Chris Glover, 2016.
3//
4//
5// Distributed under the Boost Software License, Version 1.0. (See accompanying
6// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7//
8
9#ifndef BOOST_TYPE_INDEX_RUNTIME_CAST_DETAIL_RUNTIME_CAST_IMPL_HPP
10#define BOOST_TYPE_INDEX_RUNTIME_CAST_DETAIL_RUNTIME_CAST_IMPL_HPP
11
12/// \file runtime_cast_impl.hpp
13/// \brief Contains the overload of boost::typeindex::runtime_cast for
14/// pointer types.
15///
16/// boost::typeindex::runtime_cast can be used to emulate dynamic_cast
17/// functionality on platorms that don't provide it or should the user
18/// desire opt in functionality instead of enabling it system wide.
19
20#include <boost/type_index.hpp>
21#include <boost/type_traits/integral_constant.hpp>
22
23#ifdef BOOST_HAS_PRAGMA_ONCE
24# pragma once
25#endif
26
27namespace boost { namespace typeindex {
28
29namespace detail {
30
31template<typename T, typename U>
32T* runtime_cast_impl(U* u, boost::true_type) BOOST_NOEXCEPT {
33 return u;
34}
35
36template<typename T, typename U>
37T const* runtime_cast_impl(U const* u, boost::true_type) BOOST_NOEXCEPT {
38 return u;
39}
40
41template<typename T, typename U>
42T* runtime_cast_impl(U* u, boost::false_type) BOOST_NOEXCEPT {
43 return const_cast<T*>(static_cast<T const*>(
44 u->boost_type_index_find_instance_(boost::typeindex::type_id<T>())
45 ));
46}
47
48template<typename T, typename U>
49T const* runtime_cast_impl(U const* u, boost::false_type) BOOST_NOEXCEPT {
50 return static_cast<T const*>(u->boost_type_index_find_instance_(boost::typeindex::type_id<T>()));
51}
52
53} // namespace detail
54
55}} // namespace boost::typeindex
56
57#endif // BOOST_TYPE_INDEX_RUNTIME_CAST_DETAIL_RUNTIME_CAST_IMPL_HPP