diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 41fa891ec5..22f2ff07c7 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -76,6 +76,7 @@ target_sources(common PRIVATE General.h GL/Context.h GL/StreamBuffer.h + HashCombine.h MemcpyFast.h MemsetFast.inl Path.h diff --git a/common/HashCombine.h b/common/HashCombine.h new file mode 100644 index 0000000000..ddfb4df632 --- /dev/null +++ b/common/HashCombine.h @@ -0,0 +1,26 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2021 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#pragma once + +#include +#include + +template +static inline void HashCombine(std::size_t& seed, const T& v, Rest&&... rest) +{ + seed ^= std::hash{}(v) + 0x9e3779b9u + (seed << 6) + (seed >> 2); + (HashCombine(seed, std::forward(rest)), ...); +} diff --git a/common/common.vcxproj b/common/common.vcxproj index ace384cc1d..3b5422402b 100644 --- a/common/common.vcxproj +++ b/common/common.vcxproj @@ -112,6 +112,7 @@ + diff --git a/common/common.vcxproj.filters b/common/common.vcxproj.filters index 9f5e37487f..3c7014fd22 100644 --- a/common/common.vcxproj.filters +++ b/common/common.vcxproj.filters @@ -330,6 +330,9 @@ Header Files + + Header Files + @@ -355,4 +358,4 @@ Source Files - \ No newline at end of file +