]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/util/cast_util.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
7 namespace ROCKSDB_NAMESPACE
{
8 // The helper function to assert the move from dynamic_cast<> to
9 // static_cast<> is correct. This function is to deal with legacy code.
10 // It is not recommended to add new code to issue class casting. The preferred
11 // solution is to implement the functionality without a need of casting.
12 template <class DestClass
, class SrcClass
>
13 inline DestClass
* static_cast_with_check(SrcClass
* x
) {
14 DestClass
* ret
= static_cast<DestClass
*>(x
);
15 #ifdef ROCKSDB_USE_RTTI
16 assert(ret
== dynamic_cast<DestClass
*>(x
));
20 } // namespace ROCKSDB_NAMESPACE