fork download
  1. #include <string>
  2. #include <map>
  3. #include <sstream>
  4. #include <algorithm>
  5. #include <iterator>
  6.  
  7. using namespace std;
  8.  
  9. string toString(long value)
  10. {
  11. ostringstream oss;
  12. oss << value;
  13. return oss.str();
  14. }
  15.  
  16. long hash(const string& key)
  17. {
  18. return 0;
  19. }
  20.  
  21. string generateKey()
  22. {
  23. static long value = 0;
  24. ++value;
  25. return toString(value);
  26. }
  27.  
  28. pair<string, long> generateKeyValuePair()
  29. {
  30. string key = generateKey();
  31. return make_pair(key, hash(key));
  32. }
  33.  
  34. int main()
  35. {
  36. map<string, long> hashes;
  37.  
  38. generate_n(inserter(hashes, hashes.begin()), 5, generateKeyValuePair);
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 2860KB
stdin
Standard input is empty
stdout
Standard output is empty