Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_map>
- #include <boost/utility/string_view.hpp>
- #include <boost/functional/hash.hpp>
- using namespace std;
- class Hasher {
- public:
- std::size_t operator()(boost::string_view str) const {
- return boost::hash_range<const char*>(str.begin(), str.end());
- }
- };
- int main() {
- std::unordered_map<boost::string_view, std::size_t, Hasher> m;
- m["abc"] = 123;
- m["def"] = 456;
- for (auto& elem : m)
- std::cout << elem.first << ":" << elem.second << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment