Closed smcv closed 6 years ago
After fixing #987, the macOS build has the same failure:
In file included from /Users/travis/build/smcv/OpenJK/codeJK2/game/Q3_Interface.cpp:30:
In file included from /Users/travis/build/smcv/OpenJK/codeJK2/game/g_headers.h:28:
In file included from /Users/travis/build/smcv/OpenJK/codeJK2/game/g_local.h:32:
In file included from /Users/travis/build/smcv/OpenJK/codeJK2/game/../../code/ui/gameinfo.h:27:
In file included from /Users/travis/build/smcv/OpenJK/codeJK2/game/../cgame/../../code/qcommon/q_shared.h:512:
In file included from /Users/travis/build/smcv/OpenJK/codeJK2/game/../../code/ui/../qcommon/../game/../rd-common/../game/ghoul2_shared.h:28:
/Applications/Xcode-9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/map:818:5: error: static_assert failed "Allocator::value_type must be same type as value_type"
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/travis/build/smcv/OpenJK/codeJK2/game/Q3_Interface.cpp:915:2: note: in instantiation of template class 'std::__1::map<std::__1::basic_string<char>, int, std::__1::less<std::__1::basic_string<char> >, std::__1::allocator<int> >' requested here
entlist_t::iterator ei;
^
Operating system and version:
Debian unstable (development rolling release branch) with gcc-8 8.2.0-3
Is this for single player or multiplayer?
JK2 single player
Description of the bug (and if possible, steps to reproduce the bug):
Compile with JK2 enabled. Compilation fails with several errors similar to this:
What did you expect to happen instead?
Successful compilation
Diagnosis
Several
std::map
-based typedefs in JK2 are of the formstd::map <K, V, std::less<K>, std::allocator<V>>
for some key K and value V. However,std::map
expects its 4th parameter (the allocator) to be anAllocator
that is to be used to allocate instances ofstd::pair<const K, V>
, not instances of V; so it should probably bestd::allocator<std::pair<const K, V>>
instead.std::allocator<std::pair<const K, V>>
is the default allocator anyway, so this template parameter can simply be omitted. That compiles successfully: I'll send a pull request when I've tested the resulting binaries.Similarly, the default comparator (3rd template parameter) is
std::less<K>
, so it could probably also be omitted, although this is not necessary to fix the compilation failure.