diff --git a/source/graphics/FontManager.h b/source/graphics/FontManager.h index c769bb379b..858306ebdd 100644 --- a/source/graphics/FontManager.h +++ b/source/graphics/FontManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -18,10 +18,11 @@ #ifndef INCLUDED_FONTMANAGER #define INCLUDED_FONTMANAGER -#include +#include "ps/CStrIntern.h" + +#include class CFont; -class CStrIntern; /** * Font manager: loads and caches bitmap fonts. @@ -34,7 +35,7 @@ public: private: bool ReadFont(CFont* font, CStrIntern fontName); - typedef boost::unordered_map > FontsMap; + using FontsMap = std::unordered_map >; FontsMap m_Fonts; }; diff --git a/source/graphics/MeshManager.h b/source/graphics/MeshManager.h index 9c2d9cbdb0..816e33fe92 100644 --- a/source/graphics/MeshManager.h +++ b/source/graphics/MeshManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -20,11 +20,11 @@ #include "lib/file/vfs/vfs_path.h" -#include #include +#include class CModelDef; -typedef std::shared_ptr CModelDefPtr; +using CModelDefPtr = std::shared_ptr; class CColladaManager; @@ -38,7 +38,7 @@ public: CModelDefPtr GetMesh(const VfsPath& pathname); private: - typedef boost::unordered_map > mesh_map; + using mesh_map = std::unordered_map >; mesh_map m_MeshMap; CColladaManager& m_ColladaManager; }; diff --git a/source/graphics/ObjectBase.h b/source/graphics/ObjectBase.h index df296b66bf..b8f64f7534 100644 --- a/source/graphics/ObjectBase.h +++ b/source/graphics/ObjectBase.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -18,27 +18,26 @@ #ifndef INCLUDED_OBJECTBASE #define INCLUDED_OBJECTBASE -class CModel; -class CSkeletonAnim; -class CObjectManager; -class CXeromyces; -class XMBElement; - -#include -#include -#include -#include #include "lib/file/vfs/vfs_path.h" #include "ps/CStr.h" #include "ps/CStrIntern.h" +class CModel; +class CObjectManager; +class CSkeletonAnim; +class CXeromyces; +class XMBElement; + #include +#include +#include +#include +#include class CObjectBase { NONCOPYABLE(CObjectBase); public: - struct Anim { // constructor @@ -184,14 +183,14 @@ private: // A low-quality RNG like rand48 causes visible non-random patterns (particularly // in large grids of the same actor with consecutive seeds, e.g. forests), // so use a better one that appears to avoid those patterns - typedef boost::mt19937 rng_t; + using rng_t = boost::mt19937; std::set CalculateRandomRemainingSelections(rng_t& rng, const std::vector >& initialSelections); std::vector< std::vector > m_VariantGroups; CObjectManager& m_ObjectManager; - boost::unordered_set m_UsedFiles; + std::unordered_set m_UsedFiles; void LoadVariant(const CXeromyces& XeroFile, const XMBElement& variant, Variant& currentVariant); }; diff --git a/source/graphics/ParticleManager.cpp b/source/graphics/ParticleManager.cpp index c218000fef..61ca43091c 100644 --- a/source/graphics/ParticleManager.cpp +++ b/source/graphics/ParticleManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -23,6 +23,8 @@ #include "ps/Profile.h" #include "renderer/Scene.h" +#include + static Status ReloadChangedFileCB(void* param, const VfsPath& path) { return static_cast(param)->ReloadChangedFile(path); @@ -41,7 +43,7 @@ CParticleManager::~CParticleManager() CParticleEmitterTypePtr CParticleManager::LoadEmitterType(const VfsPath& path) { - boost::unordered_map::iterator it = m_EmitterTypes.find(path); + std::unordered_map::iterator it = m_EmitterTypes.find(path); if (it != m_EmitterTypes.end()) return it->second; diff --git a/source/graphics/ParticleManager.h b/source/graphics/ParticleManager.h index 2b52bd0ede..c873fd9253 100644 --- a/source/graphics/ParticleManager.h +++ b/source/graphics/ParticleManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ #include "graphics/ParticleEmitterType.h" #include -#include +#include class SceneCollector; @@ -61,7 +61,7 @@ private: std::list m_UnattachedEmitters; - boost::unordered_map m_EmitterTypes; + std::unordered_map m_EmitterTypes; }; #endif // INCLUDED_PARTICLEMANAGER diff --git a/source/graphics/ShaderDefines.cpp b/source/graphics/ShaderDefines.cpp index c53bde5297..b3652511d3 100644 --- a/source/graphics/ShaderDefines.cpp +++ b/source/graphics/ShaderDefines.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -20,29 +20,27 @@ #include "ShaderDefines.h" #include "graphics/ShaderProgram.h" +#include "lib/hash.h" #include "maths/Vector4D.h" #include "ps/ThreadUtil.h" #include -size_t hash_value(const CVector4D& v) +namespace std { - size_t hash = 0; - boost::hash_combine(hash, v.X); - boost::hash_combine(hash, v.Y); - boost::hash_combine(hash, v.Z); - boost::hash_combine(hash, v.W); - return hash; -} - -size_t hash_value(const CShaderParams::SItems& items) +template<> +struct hash { - return items.hash; -} - -size_t hash_value(const CShaderParams::SItems& items) -{ - return items.hash; + std::size_t operator()(const CVector4D& v) const + { + size_t hash = 0; + hash_combine(hash, v.X); + hash_combine(hash, v.Y); + hash_combine(hash, v.Z); + hash_combine(hash, v.W); + return hash; + } +}; } bool operator==(const CShaderParams::SItems& a, const CShaderParams::SItems& b) @@ -180,8 +178,8 @@ void CShaderParams::SItems::RecalcHash() size_t h = 0; for (size_t i = 0; i < items.size(); ++i) { - boost::hash_combine(h, items[i].first); - boost::hash_combine(h, items[i].second); + hash_combine(h, items[i].first); + hash_combine(h, items[i].second); } hash = h; } diff --git a/source/graphics/ShaderDefines.h b/source/graphics/ShaderDefines.h index 759e746fd1..4a7f25cc1c 100644 --- a/source/graphics/ShaderDefines.h +++ b/source/graphics/ShaderDefines.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -22,8 +22,8 @@ #include "ps/CStr.h" #include "ps/CStrIntern.h" -#include #include +#include class CVector4D; @@ -96,7 +96,7 @@ public: struct SItems { // Name/value pair - typedef std::pair Item; + using Item = std::pair; // Sorted by name; no duplicated names std::vector items; @@ -106,11 +106,19 @@ public: void RecalcHash(); }; + struct SItemsHash + { + std::size_t operator()(const SItems& items) const + { + return items.hash; + } + }; + protected: SItems* m_Items; // interned value private: - typedef boost::unordered_map > InternedItems_t; + using InternedItems_t = std::unordered_map, SItemsHash >; static InternedItems_t s_InternedItems; /** @@ -188,7 +196,7 @@ enum RENDER_QUERIES class CShaderRenderQueries { public: - typedef std::pair RenderQuery; + using RenderQuery = std::pair; void Add(const char* name); size_t GetSize() const { return m_Items.size(); } diff --git a/source/graphics/ShaderManager.cpp b/source/graphics/ShaderManager.cpp index 18cb02bdd3..3c76143b2a 100644 --- a/source/graphics/ShaderManager.cpp +++ b/source/graphics/ShaderManager.cpp @@ -21,6 +21,7 @@ #include "graphics/ShaderTechnique.h" #include "lib/config2.h" +#include "lib/hash.h" #include "lib/timer.h" #include "lib/utf8.h" #include "ps/CLogger.h" @@ -335,9 +336,9 @@ static GLenum ParseBlendFunc(const CStr& str) size_t CShaderManager::EffectCacheKeyHash::operator()(const EffectCacheKey& key) const { size_t hash = 0; - boost::hash_combine(hash, key.name.GetHash()); - boost::hash_combine(hash, key.defines1.GetHash()); - boost::hash_combine(hash, key.defines2.GetHash()); + hash_combine(hash, key.name.GetHash()); + hash_combine(hash, key.defines1.GetHash()); + hash_combine(hash, key.defines2.GetHash()); return hash; } diff --git a/source/graphics/ShaderManager.h b/source/graphics/ShaderManager.h index a9d066a6e1..81e76ac244 100644 --- a/source/graphics/ShaderManager.h +++ b/source/graphics/ShaderManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -20,10 +20,6 @@ #define USE_SHADER_XML_VALIDATION 1 -#include -#include -#include - #include "graphics/ShaderDefines.h" #include "graphics/ShaderProgram.h" #include "graphics/ShaderTechnique.h" @@ -32,6 +28,9 @@ # include "ps/XML/RelaxNG.h" #endif +#include +#include +#include /** * Shader manager: loads and caches shader programs. @@ -114,11 +113,11 @@ private: size_t operator()(const EffectCacheKey& key) const; }; - typedef boost::unordered_map EffectCacheMap; + using EffectCacheMap = std::unordered_map; EffectCacheMap m_EffectCache; // Store the set of shaders that need to be reloaded when the given file is modified - typedef boost::unordered_map, std::owner_less>>> HotloadFilesMap; + using HotloadFilesMap = std::unordered_map, std::owner_less > > >; HotloadFilesMap m_HotloadFiles; bool NewProgram(const char* name, const CShaderDefines& defines, CShaderProgramPtr& program); diff --git a/source/graphics/SkeletonAnimManager.cpp b/source/graphics/SkeletonAnimManager.cpp index 722ed5af86..095676954a 100644 --- a/source/graphics/SkeletonAnimManager.cpp +++ b/source/graphics/SkeletonAnimManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -29,6 +29,7 @@ #include "ps/CLogger.h" #include "ps/FileIo.h" +#include /////////////////////////////////////////////////////////////////////////////// // CSkeletonAnimManager constructor @@ -41,7 +42,7 @@ CSkeletonAnimManager::CSkeletonAnimManager(CColladaManager& colladaManager) // CSkeletonAnimManager destructor CSkeletonAnimManager::~CSkeletonAnimManager() { - typedef boost::unordered_map::iterator Iter; + using Iter = std::unordered_map::iterator; for (Iter i = m_Animations.begin(); i != m_Animations.end(); ++i) delete i->second; } @@ -54,7 +55,7 @@ CSkeletonAnimDef* CSkeletonAnimManager::GetAnimation(const VfsPath& pathname) VfsPath name = pathname.ChangeExtension(L""); // Find if it's already been loaded - boost::unordered_map::iterator iter = m_Animations.find(name); + std::unordered_map::iterator iter = m_Animations.find(name); if (iter != m_Animations.end()) return iter->second; diff --git a/source/graphics/SkeletonAnimManager.h b/source/graphics/SkeletonAnimManager.h index deff7cf57e..373a5eba99 100644 --- a/source/graphics/SkeletonAnimManager.h +++ b/source/graphics/SkeletonAnimManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -22,10 +22,11 @@ #ifndef INCLUDED_SKELETONANIMMANAGER #define INCLUDED_SKELETONANIMMANAGER +#include "lib/file/vfs/vfs_path.h" + #include #include -#include "lib/file/vfs/vfs_path.h" -#include +#include class CColladaManager; class CSkeletonAnimDef; @@ -48,7 +49,7 @@ public: private: // map of all known animations. Value is NULL if it failed to load. - boost::unordered_map m_Animations; + std::unordered_map m_Animations; CColladaManager& m_ColladaManager; }; diff --git a/source/graphics/TextureManager.cpp b/source/graphics/TextureManager.cpp index 13c39540d0..d4f0741630 100644 --- a/source/graphics/TextureManager.cpp +++ b/source/graphics/TextureManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -19,16 +19,12 @@ #include "TextureManager.h" -#include -#include -#include -#include - #include "graphics/TextureConverter.h" #include "lib/allocators/shared_ptr.h" -#include "lib/res/h_mgr.h" #include "lib/file/vfs/vfs_tree.h" +#include "lib/hash.h" #include "lib/res/graphics/ogl_tex.h" +#include "lib/res/h_mgr.h" #include "lib/timer.h" #include "maths/MD5.h" #include "ps/CacheLoader.h" @@ -36,25 +32,31 @@ #include "ps/Filesystem.h" #include "ps/Profile.h" +#include +#include +#include + struct TPhash - : std::unary_function, - std::unary_function { std::size_t operator()(CTextureProperties const& a) const { std::size_t seed = 0; - boost::hash_combine(seed, a.m_Path); - boost::hash_combine(seed, a.m_Filter); - boost::hash_combine(seed, a.m_WrapS); - boost::hash_combine(seed, a.m_WrapT); - boost::hash_combine(seed, a.m_Aniso); - boost::hash_combine(seed, a.m_Format); + hash_combine(seed, m_PathHash(a.m_Path)); + hash_combine(seed, a.m_Filter); + hash_combine(seed, a.m_WrapS); + hash_combine(seed, a.m_WrapT); + hash_combine(seed, a.m_Aniso); + hash_combine(seed, a.m_Format); return seed; } + std::size_t operator()(CTexturePtr const& a) const { return (*this)(a->m_Properties); } + +private: + std::hash m_PathHash; }; struct TPequal_to @@ -73,17 +75,6 @@ struct TPequal_to } }; -std::size_t hash_value(const CTexturePtr& v) -{ - TPhash h; - return h(v); -} -std::size_t hash_value(const CTextureProperties& v) -{ - TPhash h; - return h(v); -} - class CTextureManagerImpl { friend class CTexture; @@ -516,17 +507,20 @@ private: CTexturePtr m_ErrorTexture; // Cache of all loaded textures - typedef boost::unordered_set TextureCache; + using TextureCache = + std::unordered_set; TextureCache m_TextureCache; // TODO: we ought to expire unused textures from the cache eventually // Store the set of textures that need to be reloaded when the given file // (a source file or settings.xml) is modified - typedef boost::unordered_map, std::owner_less>>> HotloadFilesMap; + using HotloadFilesMap = + std::unordered_map, std::owner_less > > >; HotloadFilesMap m_HotloadFiles; // Cache for the conversion settings files - typedef boost::unordered_map > SettingsFilesMap; + using SettingsFilesMap = + std::unordered_map >; SettingsFilesMap m_SettingsFiles; }; diff --git a/source/graphics/TextureManager.h b/source/graphics/TextureManager.h index 0a11bfc1aa..0c7809df90 100644 --- a/source/graphics/TextureManager.h +++ b/source/graphics/TextureManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -18,14 +18,13 @@ #ifndef INCLUDED_TEXTUREMANAGER #define INCLUDED_TEXTUREMANAGER -#include "Texture.h" +#include "graphics/Texture.h" +#include "lib/file/vfs/vfs.h" +#include "lib/ogl.h" +#include "lib/res/handle.h" #include -#include "lib/ogl.h" -#include "lib/file/vfs/vfs.h" -#include "lib/res/handle.h" - class CTextureProperties; class CTextureManagerImpl; @@ -312,7 +311,4 @@ private: std::weak_ptr m_Self; }; -std::size_t hash_value(const CTexturePtr& v); -std::size_t hash_value(const CTextureProperties& v); - #endif // INCLUDED_TEXTUREMANAGER diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index c3165d5181..847baac84b 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -40,6 +40,7 @@ #include "scriptinterface/ScriptInterface.h" #include +#include extern int g_yres; @@ -437,7 +438,7 @@ const SGUIScrollBarStyle* CGUI::GetScrollBarStyle(const CStr& style) const /** * @callgraph */ -void CGUI::LoadXmlFile(const VfsPath& Filename, boost::unordered_set& Paths) +void CGUI::LoadXmlFile(const VfsPath& Filename, std::unordered_set& Paths) { Paths.insert(Filename); @@ -474,7 +475,7 @@ void CGUI::LoadedXmlFiles() // XML Reading Xeromyces Specific Sub-Routines //=================================================================== -void CGUI::Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile, boost::unordered_set& Paths) +void CGUI::Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile, std::unordered_set& Paths) { int el_script = pFile->GetElementID("script"); @@ -524,7 +525,7 @@ void CGUI::Xeromyces_ReadRootSetup(XMBElement Element, CXeromyces* pFile) } } -void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject* pParent, std::vector >& NameSubst, boost::unordered_set& Paths, u32 nesting_depth) +void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject* pParent, std::vector >& NameSubst, std::unordered_set& Paths, u32 nesting_depth) { ENSURE(pParent); @@ -822,7 +823,7 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec delete object; } -void CGUI::Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject* pParent, std::vector >& NameSubst, boost::unordered_set& Paths, u32 nesting_depth) +void CGUI::Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject* pParent, std::vector >& NameSubst, std::unordered_set& Paths, u32 nesting_depth) { #define ELMT(x) int elmt_##x = pFile->GetElementID(#x) #define ATTR(x) int attr_##x = pFile->GetAttributeID(#x) @@ -850,7 +851,7 @@ void CGUI::Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObjec } } -void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, boost::unordered_set& Paths) +void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, std::unordered_set& Paths) { // Check for a 'file' parameter CStrW file(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("file")).FromUTF8()); diff --git a/source/gui/CGUI.h b/source/gui/CGUI.h index 1f9608f287..e88898d094 100644 --- a/source/gui/CGUI.h +++ b/source/gui/CGUI.h @@ -33,8 +33,8 @@ #include "ps/XML/Xeromyces.h" #include "scriptinterface/ScriptInterface.h" -#include #include +#include #include extern const double SELECT_DBLCLICK_RATE; @@ -120,7 +120,7 @@ public: * @param Filename Name of file * @param Paths Set of paths; all XML and JS files loaded will be added to this */ - void LoadXmlFile(const VfsPath& Filename, boost::unordered_set& Paths); + void LoadXmlFile(const VfsPath& Filename, std::unordered_set& Paths); /** * Called after all XML files linked in the page file were loaded. @@ -346,7 +346,7 @@ private: * * @see LoadXmlFile() */ - void Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile, boost::unordered_set& Paths); + void Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile, std::unordered_set& Paths); /** * Reads in the root element \ (the DOMElement). @@ -405,7 +405,7 @@ private: * * @see LoadXmlFile() */ - void Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject* pParent, std::vector >& NameSubst, boost::unordered_set& Paths, u32 nesting_depth); + void Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject* pParent, std::vector >& NameSubst, std::unordered_set& Paths, u32 nesting_depth); /** * Reads in the element \, which repeats its child \s @@ -413,7 +413,7 @@ private: * 'var' enclosed in square brackets) in its descendants' names with "[0]", * "[1]", etc. */ - void Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject* pParent, std::vector >& NameSubst, boost::unordered_set& Paths, u32 nesting_depth); + void Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject* pParent, std::vector >& NameSubst, std::unordered_set& Paths, u32 nesting_depth); /** * Reads in the element \ (the XMBElement) and executes @@ -426,7 +426,7 @@ private: * * @see LoadXmlFile() */ - void Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, boost::unordered_set& Paths); + void Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, std::unordered_set& Paths); /** * Reads in the element \ (the XMBElement) and stores the diff --git a/source/gui/GUIManager.h b/source/gui/GUIManager.h index baaec4cf78..f3d315427d 100644 --- a/source/gui/GUIManager.h +++ b/source/gui/GUIManager.h @@ -24,9 +24,9 @@ #include "ps/TemplateLoader.h" #include "scriptinterface/ScriptInterface.h" -#include -#include #include +#include +#include class CGUI; @@ -150,7 +150,7 @@ private: void PerformCallbackFunction(shared_ptr args); CStrW name; - boost::unordered_set inputs; // for hotloading + std::unordered_set inputs; // for hotloading shared_ptr initData; // data to be passed to the init() function shared_ptr gui; // the actual GUI page diff --git a/source/lib/adts/cache_adt.h b/source/lib/adts/cache_adt.h index 8f15d72c79..f64030db8f 100644 --- a/source/lib/adts/cache_adt.h +++ b/source/lib/adts/cache_adt.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -28,17 +28,10 @@ #define INCLUDED_CACHE_ADT #include - #include #include #include // std::priority_queue - -#if CONFIG_ENABLE_BOOST -# include -# define MAP boost::unordered_map -#else -# define MAP stdext::hash_map -#endif +#include /* Cache for items of variable size and value/"cost". @@ -313,7 +306,7 @@ again: } protected: - class Map : public MAP + class Map : public std::unordered_map { public: static Entry& entry_from_it(typename Map::iterator it) { return it->second; } diff --git a/source/lib/allocators/allocator_adapters.h b/source/lib/allocators/allocator_adapters.h index 17c9c55ccd..80a4c27567 100644 --- a/source/lib/allocators/allocator_adapters.h +++ b/source/lib/allocators/allocator_adapters.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -28,11 +28,11 @@ #ifndef ALLOCATOR_ADAPTERS #define ALLOCATOR_ADAPTERS -#include - #include "lib/sysdep/rtl.h" #include "lib/sysdep/vm.h" +#include + // NB: STL allocators are parameterized on the object type and indicate // the number of elements to [de]allocate. however, these adapters are // only used for allocating storage and receive the number of bytes. @@ -115,9 +115,6 @@ public: typedef ProxyAllocator other; }; - // (required to be declared by boost::unordered_map, but should never be called) - explicit NOTHROW_DEFINE ProxyAllocator(); - explicit NOTHROW_DEFINE ProxyAllocator(Allocator& allocator) : allocator(&allocator) { diff --git a/source/lib/hash.h b/source/lib/hash.h new file mode 100644 index 0000000000..1dce2c4056 --- /dev/null +++ b/source/lib/hash.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2019 Wildfire Games. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef INCLUDED_HASH +#define INCLUDED_HASH + +/** + * This function is the same as hash_combine, i.e. allows dropping the boost dependency just for this function. + */ +template +void hash_combine(std::size_t& seed, const T& val) +{ + seed ^= std::hash()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); +} + +#endif // #ifndef INCLUDED_HASH diff --git a/source/lib/path.h b/source/lib/path.h index 6f2f05956a..77cabfd4b2 100644 --- a/source/lib/path.h +++ b/source/lib/path.h @@ -37,13 +37,10 @@ #ifndef INCLUDED_PATH #define INCLUDED_PATH -#if CONFIG_ENABLE_BOOST -# include "boost/functional/hash.hpp" -#endif - #include "lib/utf8.h" #include +#include namespace ERR { @@ -73,11 +70,11 @@ LIB_API const wchar_t* path_name_only(const wchar_t* path); // NB: there is a need for 'generic' paths (e.g. for Trace entry / archive pathnames). // converting between specialized variants via c_str would be inefficient, and the -// Os/VfsPath typedefs are hopefully sufficient to avoid errors. +// Os/VfsPath types are hopefully sufficient to avoid errors. class Path { public: - typedef std::wstring String; + using String = std::wstring; Path() { @@ -307,21 +304,19 @@ static inline std::wistream& operator>>(std::wistream& s, Path& path) return s; } -#if CONFIG_ENABLE_BOOST - -namespace boost { - +namespace std +{ template<> -struct hash : std::unary_function +struct hash { std::size_t operator()(const Path& path) const { - return hash_value(path.string()); + return m_StringHash(path.string()); } -}; +private: + std::hash m_StringHash; +}; } -#endif // #if CONFIG_ENABLE_BOOST - #endif // #ifndef INCLUDED_PATH diff --git a/source/lib/res/h_mgr.cpp b/source/lib/res/h_mgr.cpp index 0a37dd7165..e03317d2a9 100644 --- a/source/lib/res/h_mgr.cpp +++ b/source/lib/res/h_mgr.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -27,7 +27,7 @@ #include "precompiled.h" #include "h_mgr.h" -#include +#include #include // CHAR_BIT #include @@ -94,9 +94,8 @@ static const u64 IDX_MASK = (1l << IDX_BITS) - 1; // - tag (1-based) ensures the handle references a certain resource instance. // (field width determines maximum unambiguous resource allocs) -typedef i64 Tag; +using Tag = i64; #define TAG_BITS 48 -static const u64 TAG_MASK = 0xFFFFFFFF; // safer than (1 << 32) - 1 // make sure both fields fit within a Handle variable cassert(IDX_BITS + TAG_BITS <= sizeof(Handle)*CHAR_BIT); @@ -109,13 +108,6 @@ static inline size_t h_idx(const Handle h) return (size_t)(h & IDX_MASK) - 1; } -// return the handle's tag field. -// no error checking! -static inline Tag h_tag(Handle h) -{ - return h >> IDX_BITS; -} - // build a handle from index and tag. // can't fail. static inline Handle handle(size_t idx, u64 tag) @@ -282,8 +274,8 @@ static Status h_data_tag_type(const Handle h, const H_Type type, HDATA*& hd) // that wasn't foreseen here, so we'll just refrain from adding to the index. // that means they won't be found via h_find - no biggie. -typedef boost::unordered_multimap Key2Idx; -typedef Key2Idx::iterator It; +using Key2Idx = std::unordered_multimap; +using It = Key2Idx::iterator; static OverrunProtector key2idx_wrapper; enum KeyRemoveFlag { KEY_NOREMOVE, KEY_REMOVE }; diff --git a/source/pch/atlas/precompiled.h b/source/pch/atlas/precompiled.h index 4f50b5d18a..9bd0a26837 100644 --- a/source/pch/atlas/precompiled.h +++ b/source/pch/atlas/precompiled.h @@ -27,6 +27,6 @@ #include "ps/CStr.h" #include "ps/Game.h" -#include +#include #endif // HAVE_PCH diff --git a/source/ps/CStr.cpp b/source/ps/CStr.cpp index 87d15753c4..1e9d73b5ae 100644 --- a/source/ps/CStr.cpp +++ b/source/ps/CStr.cpp @@ -16,8 +16,6 @@ */ /** - * File : CStr.cpp - * Project : engine * Description : Controls compilation of CStr class and * : includes some function implementations. **/ diff --git a/source/ps/CStr.h b/source/ps/CStr.h index cd2a5cdb59..22fc903fe6 100644 --- a/source/ps/CStr.h +++ b/source/ps/CStr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -16,8 +16,6 @@ */ /** - * File : CStr.h - * Project : engine * Description : Contains CStr class which is a versatile class for making string use easy. * : The class implements a series of string manipulation/formatting functions. **/ @@ -341,9 +339,4 @@ public: const u8* Deserialize(const u8* buffer, const u8* bufferend); }; -static inline size_t hash_value(const CStr& s) -{ - return s.GetHashCode(); -} - #endif diff --git a/source/ps/CStrIntern.cpp b/source/ps/CStrIntern.cpp index 96bf34a1d9..0cc9633fff 100644 --- a/source/ps/CStrIntern.cpp +++ b/source/ps/CStrIntern.cpp @@ -23,7 +23,7 @@ #include "ps/CLogger.h" #include "ps/ThreadUtil.h" -#include +#include class CStrInternInternals { @@ -49,7 +49,7 @@ private: // Interned strings are stored in a hash table, indexed by string: -typedef std::string StringsKey; +using StringsKey = std::string; struct StringsKeyHash { @@ -60,7 +60,7 @@ struct StringsKeyHash }; // To avoid std::string memory allocations when GetString does lookups in the -// hash table of interned strings, we make use of boost::unordered_map's ability +// hash table of interned strings, we make use of std::unordered_map's ability // to do lookups with a functionally equivalent proxy object: struct StringsKeyProxy @@ -85,7 +85,7 @@ struct StringsKeyProxyEq } }; -static boost::unordered_map, StringsKeyHash> g_Strings; +static std::unordered_map, StringsKeyHash> g_Strings; #define X(id) CStrIntern str_##id(#id); #define X2(id, str) CStrIntern str_##id(str); @@ -100,15 +100,7 @@ static CStrInternInternals* GetString(const char* str, size_t len) // to be thread-safe, preferably without sacrificing performance.) ENSURE(ThreadUtil::IsMainThread()); -#if BOOST_VERSION >= 104200 - StringsKeyProxy proxy = { str, len }; - boost::unordered_map >::iterator it = - g_Strings.find(proxy, StringsKeyProxyHash(), StringsKeyProxyEq()); -#else - // Boost <= 1.41 doesn't support the new find(), so do a slightly less efficient lookup - boost::unordered_map >::iterator it = - g_Strings.find(str); -#endif + std::unordered_map >::iterator it = g_Strings.find(str); if (it != g_Strings.end()) return it->second.get(); diff --git a/source/ps/CStrIntern.h b/source/ps/CStrIntern.h index 3290b7468a..34222e04c6 100644 --- a/source/ps/CStrIntern.h +++ b/source/ps/CStrIntern.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -90,9 +90,16 @@ private: CStrInternInternals* m; }; -static inline size_t hash_value(const CStrIntern& str) +namespace std { - return str.GetHash(); +template<> +struct hash +{ + std::size_t operator()(const CStrIntern& str) const + { + return str.GetHash(); + } +}; } #define X(id) extern CStrIntern str_##id; diff --git a/source/renderer/ModelRenderer.cpp b/source/renderer/ModelRenderer.cpp index f841516701..8ddbe569e4 100644 --- a/source/renderer/ModelRenderer.cpp +++ b/source/renderer/ModelRenderer.cpp @@ -17,15 +17,6 @@ #include "precompiled.h" -#include "lib/allocators/allocator_adapters.h" -#include "lib/allocators/arena.h" -#include "lib/ogl.h" -#include "maths/Vector3D.h" -#include "maths/Vector4D.h" - -#include "ps/CLogger.h" -#include "ps/Profile.h" - #include "graphics/Color.h" #include "graphics/LightEnv.h" #include "graphics/Material.h" @@ -33,7 +24,14 @@ #include "graphics/ModelDef.h" #include "graphics/ShaderManager.h" #include "graphics/TextureManager.h" - +#include "lib/allocators/allocator_adapters.h" +#include "lib/allocators/arena.h" +#include "lib/hash.h" +#include "lib/ogl.h" +#include "maths/Vector3D.h" +#include "maths/Vector4D.h" +#include "ps/CLogger.h" +#include "ps/Profile.h" #include "renderer/MikktspaceWrap.h" #include "renderer/ModelRenderer.h" #include "renderer/ModelVertexRenderer.h" @@ -338,8 +336,8 @@ struct SMRMaterialBucketKeyHash size_t operator()(const SMRMaterialBucketKey& key) const { size_t hash = 0; - boost::hash_combine(hash, key.effect.GetHash()); - boost::hash_combine(hash, key.defines.GetHash()); + hash_combine(hash, key.effect.GetHash()); + hash_combine(hash, key.defines.GetHash()); return hash; } }; @@ -424,12 +422,17 @@ void ShaderModelRenderer::Render(const RenderModifierPtr& modifier, const CShade */ Allocators::DynamicArena arena(256 * KiB); - typedef ProxyAllocator ModelListAllocator; - typedef std::vector ModelList_t; - typedef boost::unordered_map, - ProxyAllocator, Allocators::DynamicArena> - > MaterialBuckets_t; + using ModelListAllocator = ProxyAllocator; + using ModelList_t = std::vector; + using MaterialBuckets_t = std::unordered_map< + SMRMaterialBucketKey, + ModelList_t, + SMRMaterialBucketKeyHash, + std::equal_to, + ProxyAllocator< + std::pair, + Allocators::DynamicArena> >; + MaterialBuckets_t materialBuckets((MaterialBuckets_t::allocator_type(arena))); { diff --git a/source/renderer/OverlayRenderer.cpp b/source/renderer/OverlayRenderer.cpp index 7cb7b753e4..aa5f72efaa 100644 --- a/source/renderer/OverlayRenderer.cpp +++ b/source/renderer/OverlayRenderer.cpp @@ -19,11 +19,11 @@ #include "OverlayRenderer.h" -#include #include "graphics/LOSTexture.h" #include "graphics/Overlay.h" #include "graphics/Terrain.h" #include "graphics/TextureManager.h" +#include "lib/hash.h" #include "lib/ogl.h" #include "maths/MathUtil.h" #include "maths/Quaternion.h" @@ -34,10 +34,12 @@ #include "renderer/VertexArray.h" #include "renderer/VertexBuffer.h" #include "renderer/VertexBufferManager.h" -#include "simulation2/Simulation2.h" #include "simulation2/components/ICmpWaterManager.h" +#include "simulation2/Simulation2.h" #include "simulation2/system/SimContext.h" +#include + /** * Key used to group quads into batches for more efficient rendering. Currently groups by the combination * of the main texture and the texture mask, to minimize texture swapping during rendering. @@ -57,6 +59,17 @@ struct QuadBatchKey CTexturePtr m_TextureMask; }; +struct QuadBatchHash +{ + std::size_t operator()(const QuadBatchKey& d) const + { + size_t seed = 0; + hash_combine(seed, d.m_Texture); + hash_combine(seed, d.m_TextureMask); + return seed; + } +}; + /** * Holds information about a single quad rendering batch. */ @@ -79,7 +92,7 @@ public: struct OverlayRendererInternals { - typedef boost::unordered_map QuadBatchMap; + using QuadBatchMap = std::unordered_map; OverlayRendererInternals(); ~OverlayRendererInternals(){ } @@ -178,14 +191,6 @@ void OverlayRendererInternals::Initialize() quadIndices.FreeBackingStore(); } -static size_t hash_value(const QuadBatchKey& d) -{ - size_t seed = 0; - boost::hash_combine(seed, d.m_Texture); - boost::hash_combine(seed, d.m_TextureMask); - return seed; -} - OverlayRenderer::OverlayRenderer() { m = new OverlayRendererInternals(); diff --git a/source/simulation2/Simulation2.h b/source/simulation2/Simulation2.h index 3110f685a6..906d28ae47 100644 --- a/source/simulation2/Simulation2.h +++ b/source/simulation2/Simulation2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -18,26 +18,24 @@ #ifndef INCLUDED_SIMULATION2 #define INCLUDED_SIMULATION2 +#include "lib/file/vfs/vfs_path.h" +#include "scriptinterface/ScriptVal.h" +#include "simulation2/helpers/SimulationCommand.h" #include "simulation2/system/CmpPtr.h" #include "simulation2/system/Components.h" -#include "simulation2/helpers/SimulationCommand.h" -#include "scriptinterface/ScriptVal.h" - -#include "lib/file/vfs/vfs_path.h" - -#include +#include #include -class CSimulation2Impl; -class CSimContext; -class CUnitManager; -class CTerrain; -class IComponent; -class ScriptInterface; -class CMessage; -class SceneCollector; class CFrustum; +class CMessage; +class CSimContext; +class CSimulation2Impl; +class CTerrain; +class CUnitManager; +class IComponent; +class SceneCollector; +class ScriptInterface; class ScriptRuntime; /** @@ -206,8 +204,11 @@ public: void PostMessage(entity_id_t ent, const CMessage& msg) const; void BroadcastMessage(const CMessage& msg) const; - typedef std::vector > InterfaceList; - typedef boost::unordered_map InterfaceListUnordered; + using InterfaceList = + std::vector >; + + using InterfaceListUnordered = + std::unordered_map; /** * Returns a list of components implementing the given interface, and their diff --git a/source/simulation2/serialization/SerializeTemplates.h b/source/simulation2/serialization/SerializeTemplates.h index 5c06c112fd..af2a23684c 100644 --- a/source/simulation2/serialization/SerializeTemplates.h +++ b/source/simulation2/serialization/SerializeTemplates.h @@ -27,7 +27,7 @@ #include "simulation2/serialization/IDeserializer.h" #include "simulation2/serialization/ISerializer.h" -#include +#include #include template @@ -200,14 +200,14 @@ template struct SerializeUnorderedMap { template - void operator()(ISerializer& serialize, const char* name, boost::unordered_map& value) + void operator()(ISerializer& serialize, const char* name, std::unordered_map& value) { std::map ordered_value(value.begin(), value.end()); SerializeMap()(serialize, name, ordered_value); } template - void operator()(IDeserializer& deserialize, const char* name, boost::unordered_map& value) + void operator()(IDeserializer& deserialize, const char* name, std::unordered_map& value) { SerializeMap()(deserialize, name, value); } diff --git a/source/simulation2/system/ComponentManager.cpp b/source/simulation2/system/ComponentManager.cpp index dfd4fe750a..ea9e32d37a 100644 --- a/source/simulation2/system/ComponentManager.cpp +++ b/source/simulation2/system/ComponentManager.cpp @@ -19,19 +19,17 @@ #include "ComponentManager.h" -#include "DynamicSubscription.h" -#include "IComponent.h" -#include "ParamNode.h" -#include "SimContext.h" - -#include "simulation2/MessageTypes.h" -#include "simulation2/components/ICmpTemplateManager.h" - #include "lib/utf8.h" #include "ps/CLogger.h" -#include "ps/Profile.h" #include "ps/Filesystem.h" +#include "ps/Profile.h" #include "ps/scripting/JSInterface_VFS.h" +#include "simulation2/components/ICmpTemplateManager.h" +#include "simulation2/MessageTypes.h" +#include "simulation2/system/DynamicSubscription.h" +#include "simulation2/system/IComponent.h" +#include "simulation2/system/ParamNode.h" +#include "simulation2/system/SimContext.h" /** * Used for script-only message types. @@ -507,7 +505,7 @@ void CComponentManager::ResetState() } } - std::vector >::iterator ifcit = m_ComponentsByInterface.begin(); + std::vector >::iterator ifcit = m_ComponentsByInterface.begin(); for (; ifcit != m_ComponentsByInterface.end(); ++ifcit) ifcit->clear(); @@ -742,7 +740,7 @@ IComponent* CComponentManager::ConstructComponent(CEntityHandle ent, ComponentTy ENSURE((size_t)ct.iid < m_ComponentsByInterface.size()); - boost::unordered_map& emap1 = m_ComponentsByInterface[ct.iid]; + std::unordered_map& emap1 = m_ComponentsByInterface[ct.iid]; if (emap1.find(ent.GetId()) != emap1.end()) { LOGERROR("Multiple components for interface %d", ct.iid); @@ -791,7 +789,7 @@ void CComponentManager::AddMockComponent(CEntityHandle ent, InterfaceId iid, ICo // Just add it into the by-interface map, not the by-component-type map, // so it won't be considered for messages or deletion etc - boost::unordered_map& emap1 = m_ComponentsByInterface.at(iid); + std::unordered_map& emap1 = m_ComponentsByInterface.at(iid); if (emap1.find(ent.GetId()) != emap1.end()) debug_warn(L"Multiple components for interface"); emap1.insert(std::make_pair(ent.GetId(), &component)); @@ -942,7 +940,7 @@ void CComponentManager::FlushDestroyedComponents() m_ComponentCaches.erase(ent); // Remove from m_ComponentsByInterface - std::vector >::iterator ifcit = m_ComponentsByInterface.begin(); + std::vector >::iterator ifcit = m_ComponentsByInterface.begin(); for (; ifcit != m_ComponentsByInterface.end(); ++ifcit) { ifcit->erase(ent); @@ -959,7 +957,7 @@ IComponent* CComponentManager::QueryInterface(entity_id_t ent, InterfaceId iid) return NULL; } - boost::unordered_map::const_iterator eit = m_ComponentsByInterface[iid].find(ent); + std::unordered_map::const_iterator eit = m_ComponentsByInterface[iid].find(ent); if (eit == m_ComponentsByInterface[iid].end()) { // This entity doesn't implement this interface @@ -981,7 +979,7 @@ CComponentManager::InterfaceList CComponentManager::GetEntitiesWithInterface(Int ret.reserve(m_ComponentsByInterface[iid].size()); - boost::unordered_map::const_iterator it = m_ComponentsByInterface[iid].begin(); + std::unordered_map::const_iterator it = m_ComponentsByInterface[iid].begin(); for (; it != m_ComponentsByInterface[iid].end(); ++it) ret.push_back(*it); diff --git a/source/simulation2/system/ComponentManager.h b/source/simulation2/system/ComponentManager.h index b6c80c8b27..372b7f07cd 100644 --- a/source/simulation2/system/ComponentManager.h +++ b/source/simulation2/system/ComponentManager.h @@ -18,15 +18,14 @@ #ifndef INCLUDED_COMPONENTMANAGER #define INCLUDED_COMPONENTMANAGER -#include "Entity.h" -#include "Components.h" +#include "ps/Filesystem.h" #include "scriptinterface/ScriptInterface.h" #include "scriptinterface/ScriptVal.h" #include "simulation2/helpers/Player.h" -#include "ps/Filesystem.h" +#include "simulation2/system/Components.h" +#include "simulation2/system/Entity.h" #include -#include #include #include #include @@ -270,9 +269,9 @@ public: IComponent* QueryInterface(entity_id_t ent, InterfaceId iid) const; - typedef std::pair InterfacePair; - typedef std::vector InterfaceList; - typedef boost::unordered_map InterfaceListUnordered; + using InterfacePair = std::pair; + using InterfaceList = std::vector; + using InterfaceListUnordered = std::unordered_map; InterfaceList GetEntitiesWithInterface(InterfaceId iid) const; const InterfaceListUnordered& GetEntitiesWithInterfaceUnordered(InterfaceId iid) const; @@ -353,7 +352,7 @@ private: // TODO: some of these should be vectors std::map m_ComponentTypesById; std::vector m_ScriptedSystemComponents; - std::vector > m_ComponentsByInterface; // indexed by InterfaceId + std::vector > m_ComponentsByInterface; // indexed by InterfaceId std::map > m_ComponentsByTypeId; std::map > m_LocalMessageSubscriptions; std::map > m_GlobalMessageSubscriptions; diff --git a/source/tools/atlas/GameInterface/DeltaArray.h b/source/tools/atlas/GameInterface/DeltaArray.h index f43437af20..df952bf8dc 100644 --- a/source/tools/atlas/GameInterface/DeltaArray.h +++ b/source/tools/atlas/GameInterface/DeltaArray.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -35,18 +35,34 @@ protected: virtual void setNew(ssize_t x, ssize_t y, const T& val) = 0; private: - std::size_t hash_value(const std::pair& p) + // TODO: more efficient representation + using Data = std::unordered_map, std::pair >; // map of -> + Data m_Data; +}; + +namespace std +{ +template<> +struct hash > +{ + std::size_t operator()(const std::pair& p) const { std::size_t seed = 0; - boost::hash_combine(seed, p.first << 16); - boost::hash_combine(seed, p.second); + hash_combine(seed, p.first << 16); + hash_combine(seed, p.second); return seed; } - // TODO: more efficient representation - typedef boost::unordered_map, std::pair > Data; // map of -> - Data m_Data; + // Same as boost::hash_combine + void hash_combine(std::size_t& seed, const ssize_t val) const + { + seed ^= m_SizeHash(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + } + +private: + std::hash m_SizeHash; }; +} //////////////////////////////////////////////////////////////////////////