1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PANDA_VERIFICATION_UTIL_MISC_H_ 17 #define PANDA_VERIFICATION_UTIL_MISC_H_ 18 19 #include <functional> 20 #include <cstddef> 21 #include <tuple> 22 23 namespace std { 24 25 template <typename T1, typename T2> 26 struct hash<std::pair<T1, T2>> { 27 size_t operator()(const std::pair<T1, T2> &pair) const 28 { 29 return std::hash<T1> {}(pair.first) ^ std::hash<T2> {}(pair.second); 30 } 31 }; 32 33 template <class T, class Tuple> 34 struct tuple_type_index; 35 36 template <class T, class... Types> 37 struct tuple_type_index<T, tuple<T, Types...>> { 38 static constexpr size_t value = 0; 39 }; 40 41 template <class T, class U, class... Types> 42 struct tuple_type_index<T, tuple<U, Types...>> { 43 static constexpr size_t value = 1 + tuple_type_index<T, tuple<Types...>>::value; 44 }; 45 46 } // namespace std 47 48 #endif // PANDA_VERIFICATION_UTIL_MISC_H_ 49