Skip to content

Instantly share code, notes, and snippets.

@strangeglyph
Created January 19, 2019 16:44
Show Gist options
  • Save strangeglyph/35dd47b6b9a02d407e482672b855e91d to your computer and use it in GitHub Desktop.
Save strangeglyph/35dd47b6b9a02d407e482672b855e91d to your computer and use it in GitHub Desktop.
#include <memory>
#include <unordered_map>
/// --------------
class ImplBase;
class Class {
std::unique_ptr<ImplBase> impl;
public:
size_t foo() const;
bool operator ==(const Class &other);
};
namespace std {
template <>
struct hash<Class> {
size_t operator ()(const Class &cls) const {
return cls.foo();
}
};
}
using MyMap = std::unordered_map<Class, size_t>;
void foo() {
MyMap map = MyMap();
}
#include "a.h"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment