Last active
December 18, 2015 01:48
-
-
Save FinchPowers/5706305 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <city.h> | |
#include <sstream> | |
void michHashInternal(std::stringstream& ss){} | |
template<typename first, typename... args> | |
void michHashInternal(std::stringstream& ss, first&& f, args&&... a){ | |
ss << std::forward<first>(f); | |
michHashInternal(ss, std::forward<args>(a)...); | |
} | |
template<typename... args> | |
uint64 michHash(args&&... a){ | |
std::stringstream ss; | |
michHashInternal(ss, std::forward<args>(a)...); | |
std::string str = ss.str(); | |
return CityHash64(str.c_str(), str.length()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
get rid of first on michHash.
argument passing should be either be std::forwarded (so add a && to the arguments and std::forward(f) on access or do it by const&. For both functions.
Get rid of strlen. You already have the size in ss.str() so avoid recomputing it.