/** * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef PANDA_VERIFIER_UTIL_MISC_HPP_ #define PANDA_VERIFIER_UTIL_MISC_HPP_ #include "libpandabase/utils/hash.h" #include #include #include namespace ark::verifier { template size_t StdHash(const T &x) { return std::hash {}(x); } } // namespace ark::verifier namespace std { template struct hash> { size_t operator()(const std::pair &pair) const { return ark::MergeHashes(ark::verifier::StdHash(pair.first), ark::verifier::StdHash(pair.second)); // NOLINT } }; template struct hash> { template size_t Helper(size_t tmpHash, const std::tuple &tuple) const { if constexpr (N < sizeof...(T)) { size_t tmp_hash1 = ark::MergeHashes(tmpHash, ark::verifier::StdHash(std::get(tuple))); // NOLINT return Helper(tmp_hash1, tuple); } return tmpHash; } size_t operator()(const std::tuple &tuple) const { return Helper<1>(ark::verifier::StdHash(std::get<0>(tuple)), tuple); } }; } // namespace std #endif // !PANDA_VERIFIER_UTIL_MISC_HPP_