// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_ALGORITHM_CORE_HPP #define NAZARA_ALGORITHM_CORE_HPP #include #include #include #include #include #include #include #include #include namespace Nz { class ByteArray; template decltype(auto) AccessByOffset(void* basePtr, std::size_t offset); template decltype(auto) AccessByOffset(const void* basePtr, std::size_t offset); template constexpr T Align(T offset, T alignment); template constexpr T AlignPow2(T offset, T alignment); template decltype(auto) Apply(F&& fn, Tuple&& t); template decltype(auto) Apply(O& object, F&& fn, Tuple&& t); template constexpr std::size_t BitCount(); template ByteArray ComputeHash(HashType hash, const T& v); template ByteArray ComputeHash(AbstractHash* hash, const T& v); template constexpr std::size_t CountOf(T(&name)[N]) noexcept; template std::size_t CountOf(const T& c); inline bool HashAppend(AbstractHash* hash, const std::string_view& v); template void HashCombine(std::size_t& seed, const T& v); template bool IsPowerOfTwo(T value); template T ReverseBits(T integer); template constexpr auto UnderlyingCast(T value) -> std::underlying_type_t; template struct AlwaysFalse : std::false_type {}; template struct OverloadResolver { template constexpr auto operator()(R(T::* ptr)(Args...)) const noexcept { return ptr; } template constexpr auto operator()(R(T::* ptr)(Args...) const) const noexcept { return ptr; } template constexpr auto operator()(R(*ptr)(Args...)) const noexcept { return ptr; } }; template constexpr OverloadResolver Overload = {}; template struct PointedType { using type = void; //< FIXME: I can't make SFINAE work }; template bool Serialize(SerializationContext& context, T&& value); inline bool Serialize(SerializationContext& context, bool value, TypeTag); inline bool Serialize(SerializationContext& context, const std::string& value, TypeTag); template std::enable_if_t::value, bool> Serialize(SerializationContext& context, T value, TypeTag); template bool Unserialize(SerializationContext& context, T* value); inline bool Unserialize(SerializationContext& context, bool* value, TypeTag); inline bool Unserialize(SerializationContext& context, std::string* value, TypeTag); template std::enable_if_t::value, bool> Unserialize(SerializationContext& context, T* value, TypeTag); } #include #endif // NAZARA_ALGORITHM_CORE_HPP