Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ WeaponType hash compilation error on gcc version 5.4.0 (ubuntu 16.04) #8

Open
tsarevfs opened this issue Nov 27, 2019 · 0 comments

Comments

@tsarevfs
Copy link

Old gcc has only partial C++17 support. There is known issue with enum hashes:
https://stackoverflow.com/a/29618545/1762922

In file included from /usr/include/c++/5/bits/hashtable.h:35:0,
                 from /usr/include/c++/5/unordered_map:47,
                 from /home/ftsarev/Downloads/cpp/model/Properties.hpp:10,
                 from /home/ftsarev/Downloads/cpp/model/Game.hpp:7,
                 from /home/ftsarev/Downloads/cpp/MyStrategy.hpp:6,
                 from /home/ftsarev/Downloads/cpp/MyStrategy.cpp:1:
/usr/include/c++/5/bits/hashtable_policy.h: In instantiation of ‘struct std::__detail::__is_noexcept_hash<WeaponType, std::hash<WeaponType> >’:
/usr/include/c++/5/type_traits:137:12:   required from ‘struct std::__and_<std::__is_fast_hash<std::hash<WeaponType> >, std::__detail::__is_noexcept_hash<WeaponType, std::hash<WeaponType> > >’
/usr/include/c++/5/type_traits:148:38:   required from ‘struct std::__not_<std::__and_<std::__is_fast_hash<std::hash<WeaponType> >, std::__detail::__is_noexcept_hash<WeaponType, std::hash<WeaponType> > > >’
/usr/include/c++/5/bits/unordered_map.h:100:66:   required from ‘class std::unordered_map<WeaponType, WeaponParams>’
/home/ftsarev/Downloads/cpp/model/Properties.hpp:41:50:   required from here
/usr/include/c++/5/bits/hashtable_policy.h:85:34: error: no match for call to ‘(const std::hash<WeaponType>) (const WeaponType&)’
  noexcept(declval<const _Hash&>()(declval<const _Key&>()))>
                                  ^
In file included from /usr/include/c++/5/bits/move.h:57:0,
                 from /usr/include/c++/5/bits/stl_pair.h:59,
                 from /usr/include/c++/5/bits/stl_algobase.h:64,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/string:40,
                 from /home/ftsarev/Downloads/cpp/Stream.hpp:4,
                 from /home/ftsarev/Downloads/cpp/Debug.hpp:4,
                 from /home/ftsarev/Downloads/cpp/MyStrategy.hpp:4,
                 from /home/ftsarev/Downloads/cpp/MyStrategy.cpp:1:
/usr/include/c++/5/type_traits: In instantiation of ‘struct std::__not_<std::__and_<std::__is_fast_hash<std::hash<WeaponType> >, std::__detail::__is_noexcept_hash<WeaponType, std::hash<WeaponType> > > >’:
/usr/include/c++/5/bits/unordered_map.h:100:66:   required from ‘class std::unordered_map<WeaponType, WeaponParams>’
/home/ftsarev/Downloads/cpp/model/Properties.hpp:41:50:   required from here
/usr/include/c++/5/type_traits:148:38: error: ‘value’ is not a member of ‘std::__and_<std::__is_fast_hash<std::hash<WeaponType> >, std::__detail::__is_noexcept_hash<WeaponType, std::hash<WeaponType> > >’
     : public integral_constant<bool, !_Pp::value>

Workaround is to define std::hash specialization for WeaponType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant