Skip to content

Commit

Permalink
Update gtl::Hash so that std::hash<Foo*> can be overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Oct 1, 2022
1 parent 47fe779 commit aa66e64
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
40 changes: 40 additions & 0 deletions docs/new_release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- update version in gtl_config.hpp
- update version in comment on top of CMakeLists.txt and in README.md
- git commit
- git push
- create the new release on github (tag `v1.1.5` - use semantic versioning)
- download the tar.gz from github, and use `sha256sum gtl-1.1.5.tar.gz` on linux to get the sha256

## conan

- fork and clone [conan-center repo](https://github.com/conan-io/conan-center-index)
(or sync + git pull)
- git checkout -b gtl_1.1.5
- update: `recipes/gtl/all/conandata.yml` and `recipes/gtl/config.yml`
- sudo pip install conan -U
- cd recipes/gtl/all
- conan create conanfile.py gtl/1.1.5@ -pr:b=default -pr:h=default
- git diff
- git commit ...
- git push origin gtl_1.1.5
- create PR like [this](https://github.com/conan-io/conan-center-index/pull/13161)


## vcpkg

- fork and clone [vcpkg repo](https://github.com/microsoft/vcpkg)
(or sync + git pull)
- git checkout -b gtl_1.1.5
- update ports/gtl/portfile.cmake and ports/gtl/vcpkg.json

in windows, non-cygwin console

- set VCPKG_ROOT=
- vcpkg install gtl --triplet x64-windows
- # update sha in portfile.cmake
- git diff
- git commit ...
- vcpkg x-add-version --all --overwrite-version ## (or ./vcpkg.exe --no-dry-run upgrade )
- git diff
- git commit ...
- git push origin gtl_1.1.5
4 changes: 3 additions & 1 deletion include/gtl/phmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4932,7 +4932,9 @@ struct HashEq<T*>
using is_transparent = void;
template <class U>
size_t operator()(const U& ptr) const {
return gtl::Hash<const T*>{}(HashEq::ToPtr(ptr));
// we want phmap::Hash<T*> and not phmap::Hash<const T*>
// so "struct std::hash<T*> " override works
return gtl::Hash<T*>{}((T*)(uintptr_t)HashEq::ToPtr(ptr));
}
};

Expand Down
9 changes: 0 additions & 9 deletions include/gtl/phmap_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,6 @@ struct Hash
}
};

template <class T>
struct Hash<T *>
{
inline size_t operator()(const T *val) const noexcept
{
return static_cast<size_t>(reinterpret_cast<const uintptr_t>(val));
}
};

template<class ArgumentType, class ResultType>
struct gtl_unary_function
{
Expand Down

0 comments on commit aa66e64

Please sign in to comment.