Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
unordered map broken msvc
#include <unordered_map> #include <functional> #include <algorithm> template<class A, class B> std::pair<B, A> flippedPair(const std::pair<A, B> & _pair) { return std::pair<B, A>(_pair.second, _pair.first); } template< class KeyTy, class MappedTy, class NewHasher = std::hash<MappedTy>, class NewKeyeq = std::equal_to<MappedTy>, class NewAlloc = std::allocator<std::pair<const MappedTy, KeyTy> >, template<class ...> class MapT, class ... Ts> auto flipped_unorderedMap(MapT<KeyTy, MappedTy, Ts ...> const& _src, NewHasher * = (std::hash<MappedTy>*)0, NewKeyeq * = (std::equal_to<MappedTy>*)0, NewAlloc * = (std::allocator<std::pair<const MappedTy, KeyTy>>*)0 ) { MapT<MappedTy, KeyTy, NewHasher, NewKeyeq, NewAlloc > dst; std::transform(_src.begin(), _src.end(), std::inserter(dst, dst.begin()), &flippedPair<KeyTy, MappedTy>); return dst; } int main( ) { std::unordered_map<int , int, std::hash<int> > map; // = {{0,1 }, {2, 4 }, {1, 3 } } ; auto nmap = flipped_unorderedMap(map, (std::hash<int>*)nullptr); }
run
|
edit
|
history
|
help
0
Visual Studio 2015 Compiler Bug: 64bit multiplication
Wide string to lowercase
Type deduction in VC++
visual-wtf
du
Error with move capture of a const ref in a lambda function
imdying
hangman
Workaround for https://github.com/Project-OSRM/osrm-backend/pull/4385
hangman