]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/util/cast_util.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rocksdb / util / cast_util.h
CommitLineData
11fdf7f2
TL
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
f67539c2 8namespace ROCKSDB_NAMESPACE {
11fdf7f2
TL
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.
13template <class DestClass, class SrcClass>
14inline 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}
f67539c2 21} // namespace ROCKSDB_NAMESPACE