/* * WiVRn VR streaming * Copyright (C) 2022 Guillaume Meunier * Copyright (C) 2022 Patrick Nicolas * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 this program. If not, see . */ #pragma once #include #include #include #include namespace utils { template struct is_vk_flags : std::false_type {}; template struct is_vk_flags> : std::true_type {}; template struct is_std_vector : std::false_type {}; template struct is_std_vector> : std::true_type {}; template struct magic_hash { std::size_t operator()(const T & info) const noexcept { size_t h = 0; boost::pfr::for_each_field(info, [&](const auto & member) { using U = std::remove_cvref_t; if constexpr (is_vk_flags::value) { using V = U::MaskType; std::hash hasher; h = std::rotl(h, 5) ^ hasher(static_cast(member)); } else if constexpr (is_std_vector::value) { std::hash hasher; for (const auto & i: member) h = std::rotl(h, 5) ^ hasher(i); } else { std::hash hasher; h = std::rotl(h, 5) ^ hasher(member); } }); return h; } }; } // namespace utils