]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/util/cast_util.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / 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).
5
6 #pragma once
7
8 namespace rocksdb {
9 // The helper function to assert the move from dynamic_cast<> to
10 // static_cast<> is correct. This function is to deal with legacy code.
11 // It is not recommanded to add new code to issue class casting. The preferred
12 // solution is to implement the functionality without a need of casting.
13 template <class DestClass, class SrcClass>
14 inline DestClass* static_cast_with_check(SrcClass* x) {
15 DestClass* ret = static_cast<DestClass*>(x);
16 #ifdef ROCKSDB_USE_RTTI
17 assert(ret == dynamic_cast<DestClass*>(x));
18 #endif
19 return ret;
20 }
21 } // namespace rocksdb